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: Row[]; // Required. Block-editor rows: { id, size, columns: [{ id, size, data }] }
meta_title: string; // SEO title (required)
meta_description?: string;
meta_keywords?: 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: [{ id: 'r1', size: 1, columns: [{ id: 'c1', size: 1, data: { blocks: [] } }] }],
meta_title: 'About Our Store'
});
Notes
- Raw HTML blocks in
contentare sanitized before saving (sanitizeRawHtml); other blocks are sanitized when the page renders sizevalues follow the admin editor. A column'ssizeis its width in grid units, 1 to 3. A row'ssizeis the sum of its column sizes, 1 to 5: a 1:2 row is{ size: 3, columns: [{ size: 1 }, { size: 2 }] }. Other values fall back to one column.- 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