createPage
Create a new CMS page with content, URL, and SEO metadata.
Import
import { createPage } from '@evershop/evershop/cms/services';
Syntax
createPage(data: PageData, context?: Record<string, any>): Promise<CmsPageRow>
Parameters
data
Type: PageData
{
name: string; // Page title (required)
status: '0' | '1'; // Published status (required)
url_key: string; // URL slug (required)
content: string; // Page content - EditorJS JSON (required)
meta_title: string; // SEO title (required)
meta_description?: string;
meta_keywords?: string;
layout?: string;
}
context
Type: Record<string, any> (optional)
Context object passed to hooks.
Return Value
Returns Promise with the created page data including generated cms_page_id and uuid.
Examples
import { createPage } from '@evershop/evershop/cms/services';
const page = await createPage({
name: 'About Us',
status: '1',
url_key: 'about-us',
content: '{"blocks":[]}',
meta_title: 'About Our Store'
});
Notes
- Content is sanitized for XSS before saving
- Data is validated against a JSON schema
- Wrapped in a database transaction
- Uses hookable pattern for extensibility
See Also
- browFiles - Browse uploaded files
- uploadFile - Upload a file