Skip to content

contentHelper

contentHelper(slug, pkg?): Promise<ContentHelperTempResponse>

A helper function to get the content of a page by its slug.

Parameters

slug: string

The slug of the page to get the content of. Defined in the PageData table.

pkg?: string

The package to get the content from. Default is ‘@astrolicious/studiocms’.

Returns

Promise<ContentHelperTempResponse>

The data and content of the page.

Example

---
// Get the content of the index page:
import { StudioCMSRenderer, contentHelper } from 'studiocms:components'
const { title, description, heroImage, content } = await contentHelper("index", "@astrolicious/studiocms")
---
<h1>{title}</h1>
<p>{description}</p>
<img src={heroImage} alt={title} />
<StudioCMSRenderer content={content} />

Defined in

packages/studiocms_core/src/helpers/contentHelper.ts:58