Skip to content

feature-content-blocks setup

Styles

Import them once, in the stylesheet where you load Tailwind:

@import "@evolve-storefront/feature-content-blocks/styles.css";

Translations

The package ships its texts in @evolve-storefront/feature-content-blocks/messages. evolve messages merges them into your message files and never overwrites a text you changed.

ContentAudienceProvider

Tells the blocks below it who is looking. Mount it once, high in the layout, with the session the browser knows. An editor's preview passes the audience it previews.

import { ContentAudienceProvider } from "@evolve-storefront/feature-content-blocks/content-audience";
PropTypeDescription
audiencesreadonly AudienceType[] | undefined

The audiences the visitor belongs to, EVERYONE implied. undefined while the session is not known yet: blocks with an audience then keep their space, hidden.

children?ReactNode

Prefetching on the server

Fetch the data in a Server Component so the page renders with it instead of a skeleton.

contentPageQueryOptionsA content page by path.
import { contentPageQueryOptions } from "@evolve-storefront/feature-content-blocks/queries";

path is the CMS's own path, without a locale segment — the gateway resolves the locale from the store context.

function contentPageQueryOptions(
args: ContentQueryArgs & { path: string; },
): OmitKeyof<UseQueryOptions<ContentPage | null, Error, ContentPage | null, readonly ["content", "page", string, ContentVersion, string | null]>, "queryFn"> & { qu…
contentSnippetQueryOptionsA reusable content snippet by its key.
import { contentSnippetQueryOptions } from "@evolve-storefront/feature-content-blocks/queries";
function contentSnippetQueryOptions(
args: ContentQueryArgs & { key: string; },
): OmitKeyof<UseQueryOptions<ContentSnippet | null, Error, ContentSnippet | null, readonly ["content", "snippet", string, ContentVersion, string | null]>, "queryFn…
siteSettingsQueryOptionsWhich page answers each recurring purpose (contact, terms, privacy, cookies, returns, shipping); null where the store has no settings entry yet.
import { siteSettingsQueryOptions } from "@evolve-storefront/feature-content-blocks/queries";
function siteSettingsQueryOptions(
args: ContentQueryArgs,
): OmitKeyof<UseQueryOptions<SiteSettings | null, Error, SiteSettings | null, readonly ["content", "site-settings", ContentVersion, string | null]>, "queryFn"> & {…
OptionTypeDescription
gqlClientClientFetcher
version?ContentVersion

DRAFT returns unpublished edits and must never be the default: it is what an editor's preview asks for, and serving it to a shopper publishes work in progress. Defaults to PUBLISHED.

previewId?string

The CMS's preview session, which selects whose draft to return.

enabled?boolean