# frontend — `createContentHelpers`, `createPageRoute`, `SiteProviders` The layer the project wires into `app/`: one helper factory (`src/lib/content.ts`), a ready catch-all page and a component with the layout providers. All optional — each piece has a lower-level equivalent (content.md, seo.md, links.md). ## `createContentHelpers` → `src/lib/content.ts` ```ts // src/lib/content.ts import { createContentHelpers } from '@intecion/ipal-kit' import config from '@payload-config' import { contentConfig } from '@/content.config' import { i18nConfig } from '@/i18n.config' export const { getCachedPayload, getSettings, resolveRoute, getEntries, generateStaticParams, generatePageMetadata, getSiteShell, sitemap, robots, /* … */ } = createContentHelpers({ config, content: contentConfig, i18n: i18nConfig }) ``` All reads are wrapped in React `cache()`; the Payload instance is created once in the factory and shared by the helpers (generateMetadata and the page share queries). ### Options | Option | Default | What it does | |---|---|---| | `config` | — (required) | Payload config (promise or object) | | `content` | — | the same `ContentOption` as in the plugin (content.md) | | `i18n` | — | `I18nConfig`; **without it these throw**: `generatePageMetadata`, `getPageJsonLd`, `sitemap`, `getLinkOptions`/`resolveLink`/`resolveNav`/`getSystemLinks`, `resolvePageRedirect`, `getConstructionMode`, `getSiteShell`, `llmsRoute`, `llmsFullRoute`, `mcpGET`/`mcpPOST`, `manifest` | | `baseUrl` | `NEXT_PUBLIC_SERVER_URL`, then `''` | origin for sitemap/robots/canonical/JSON-LD | | `pagesSlug` | `'pages'` | pages collection | | `settingsSlug` | `'site-settings'` | SiteSettings global | | `redirectCollections` | `[{ slug: 'pages' }]` | collections checked by `resolvePageRedirect` (slug history) | | `markdown` | — | `{ frontmatter, layoutField, overrides, isPathVisible }` for `markdownRoute` (`isPathVisible` defaults to the helper below; `() => true` = no construction filter) | | `markdownAlternate` | off | `true`/prefix → `generatePageMetadata` adds `` (indexable pages) | | `mcp` | — | `{ serverName, serverVersion, rateLimit, maxBatch, clientIp, isPathVisible }` for `mcpGET`/`mcpPOST` (mcp.md) | | `pageJsonLd` | — | default `getPageJsonLd` options: `breadcrumbs`, `entryType`, `entries`, `faq`, `pageType` | | `robots` | — | `RobotsOptions` for `robots` and `getRobots` (seo.md); `aiBotRules: [{ userAgent, access }]` = per-bot exceptions from code (the panel's rules come after them) | | `settingsDepth` | `1` | depth of `getSettings`: Site settings relations arrive as documents, theirs as ids (the archive page is read separately at depth 2); `2` = every request pays for more | | `siteJsonLd` | WebSite + Organization from Site settings | a function replaces it, `false` = none | | `sitemapEntries` | — | `(entries) => entries` — final sitemap list: add URLs of your own routes, remove some, set `priority` | | `sitemapImages` | the document's SEO image | `(doc) => url[]` | | `sitemapOptions` | `{ maxUrls: 10000, cacheControl: 'public, max-age=0, s-maxage=3600, stale-while-revalidate=86400', memoSeconds: 300 }` | `sitemapRoute`: above `maxUrls` it serves a `` with `?part=N` parts (`Infinity` = never split); `cacheControl: false` = no header; `memoSeconds: 0` = no in-process memo | | `sitemapStyle` | built-in style | `false` = raw XML | | `summaryField` | — | field from `buildSummaryField` for llms.txt / MCP | | `underConstructionSeo` | `true` | under construction the sitemap and llms.txt list only the open pages; `false` = list everything | ### Returned keys (what `@/lib/content` exports) | Key | Signature / usage | |---|---| | `getCachedPayload` | `() => Promise` | | `getConfiguredLocales` | `() => Promise` (from `config.localization`) | | `getSettings` | `(locale)` — SiteSettings, `depth: 1` (`settingsDepth`), one read per language per request | | `resolveRoute` | `(locale, segments, page)` → `ResolvedRoute \| null` (content.md) | | `getEntries` | `(collection, locale, page, perPage)` → `ArchiveEntries` | | `getNotFoundPage` | `(locale)` — 404 page from System pages or `null`, does not throw (pages.md) | | `generatePageMetadata` | `(locale, segments, page = 1)` → `Metadata` for `generateMetadata` | | `getPageJsonLd` | `(locale, segments, options?)` → nodes for `` (WebPage / BlogPosting / CollectionPage, BreadcrumbList, FAQPage); `[]` for noindex | | `generateStaticParams` | see below | | `sitemap` | `app/sitemap.ts`: `export { sitemap as default }` (does not split; a database error throws at runtime, `[]` only during `next build`) | | `sitemapRoute` | `app/sitemap.xml/route.ts`: `export { sitemapRoute as GET }` | | `robots` | `app/robots.ts`: `export { robots as default }` — rules from code only (sync) | | `getRobots` | `app/robots.ts`: `export { getRobots as default }` + `export const dynamic = 'force-dynamic'` — `robots` plus the AI crawler policy and per-bot rules from Site settings → Search engines, read per request; database unreachable → the code options | | `manifest` | `app/manifest.ts`: `export { manifest as default }` | | `llmsRoute`, `llmsFullRoute` | `app/llms.txt/route.ts`, `app/llms-full.txt/route.ts` (seo.md) | | `markdownRoute` | `app/md/[locale]/[[...slug]]/route.ts` (content.md) | | `mcpGET`, `mcpPOST` | `app/api/mcp/route.ts` (mcp.md) | | `healthRoute` | `app/api/health/route.ts` | | `indexNowKeyRoute` | IndexNow key file route (seo.md) | | `getHomeSlug` | `(locale)` — home page slug | | `getLinkOptions` | `(locale)` — options for `resolveLinkHref` / `RenderForm linkOptions` (with `content` archives) | | `resolveLink`, `resolveNav`, `getSystemLinks` | links.md | | `resolvePageRedirect` | `(locale, segments)` → new path from slug history or `null` | | `getConstructionMode` | `(locale)` — under-construction mode state (construction.md) | | `isPathVisible` | `(path, locale)` → `Promise` — `false` for a page construction mode hides (path as a visitor sees it, `/pl/o-nas`); already wired into `markdownRoute` and `mcpPOST`, pass it to `createSearchRoute({ …, isPathVisible })`; concurrent calls share one mode read per locale | | `getFormTexts` | `(locale)` — form texts from Notifications | | `getSiteShell` | `(locale)` → `SiteShell` for the layout (consent, analytics, turnstile, jsonLd, settings, theme, formTexts) | | `i18n` | the `I18nConfig` passed in | ### `generateStaticParams` — what it really generates The docstring of `generateStaticParams` in `createContentHelpers.ts` talks about content collections, but the code queries **only the `pagesSlug` collection**, `limit: 1000` per language, no pagination: - home page → `slug: []` (root); the page assigned as 404 and the slugs `404`/`500`/`error`/`not-found` are skipped, - drafts filtered out in memory, `noindex` pages **stay** (they must render), - one language → `{ slug }[]`, several → `{ locale, slug }[]`, - **`content` collection entries and archive pages > 1 are not generated**, nor more than 1000 pages per language — they render on request, - database unreachable during the build → `[]` + a warning. Entries as SSG: your own `generateStaticParams` that merges the helper's result with `buildEntryPath`/a query for entries. ## `createPageRoute` — catch-all page (`/rsc`) ```tsx // app/(frontend)/[locale]/[[...slug]]/page.tsx import { notFound, permanentRedirect, redirect } from 'next/navigation' import { createPageRoute } from '@intecion/ipal-kit/rsc' import * as content from '@/lib/content' import { blockRegistry } from '@/blocks/registry' export const revalidate = 3600 // literal in the file const route = createPageRoute(content, { blocks: blockRegistry, notFound, permanentRedirect, redirect }) export default route.Page export const generateMetadata = route.generateMetadata export const generateStaticParams = route.generateStaticParams ``` Order in `Page`: under-construction mode (when `redirect` is passed) → `resolveRoute(locale, segments, 1)` → no route: `resolvePageRedirect` (308) or `onMissing` → home page slug at its own address: 308 to root (`homeAlias`) → `RenderBlocks` with `{ locale, isFirst, firstImage, …blockProps }` → `render` (optional) → ``. `isFirst` / `firstImage` come from `blockPosition({ allBlocks, index })` (root): the first section (its heading is the page's `h1`) and "no block before this one shows an image" (its first image is the LCP image; `blockHasImage(data)` checks a block's data). Your own `enhanceProps` can spread `blockPosition(args)` the same way. | Option | Default | What it does | |---|---|---| | `blocks` | — (required) | `blockType → component` registry | | `notFound`, `permanentRedirect` | — (required) | from `next/navigation` (injected) | | `redirect` | — | from `next/navigation`; turns on under-construction mode and `onMissing: 'redirectHome'` | | `onMissing` | `'notFound'` | `'redirectHome'` (307 to the home page) or a function `({ locale, segments }) => …` | | `homeAlias` | `'redirect'` | `false` = the home page also renders at its own slug | | `blockProps` | — | `({ doc, locale }) => props` for every block | | `render` | — | `({ route, blocks, locale, segments }) => ReactNode \| undefined` — your own archive/entry view | | `jsonLd` | `true` | `false` or `getPageJsonLd` options | | `layoutField` | `'layout'` | field with the blocks | **Limitation:** always page 1 — `?page=` is not read (archive pagination: content.md). No `[locale]` in params → `i18n.defaultLocale` (single-language site). 404: `createNotFoundPage` / `renderNotFoundView` — pages.md. ## `SiteProviders` — layout (`/rsc`) ```tsx // app/(frontend)/[locale]/layout.tsx import { SiteProviders } from '@intecion/ipal-kit/rsc' import { getSiteShell } from '@/lib/content'
{children}