AI / GEO: - feat(content): lexicalToMarkdown, blocksToMarkdown, createMarkdownRenderer (+markdownResponse) — per-page Markdown for AI agents - feat(content): markdown content negotiation + discovery (prefersMarkdown, markdownHref) - feat(seo): buildRobots aiBots policy (allow/block-training/disallow) - feat(seo): llms-full.txt mode in buildLlmsTxt/createLlmsTxtRoute - feat(mcp): createMcpRoute — read-only MCP server (search_content, get_page) - feat(content): searchContent + createSearchRoute — shared JSON search - feat(seo): buildSpeakableJsonLd + buildSummaryField (aiSummary, auto-fill) Forms: - feat(forms): useForm/useContactForm + validators (logic-only, no markup) - feat(forms): honeypot anti-spam (honeypotInputProps, isHoneypotTripped) Helpers / hardening: - feat(i18n): resolveLocalized — replaces ad-hoc getSafeString - feat(hooks): buildCrossLocaleFieldSync — locales from config, no hardcoded list - feat(seo): buildNoindexField — checkbox → meta.noindex, no - feat(content): resolveRedirect — 301/308 from slugHistory - feat(env): assertEnv + ipalEnvRules — fail-fast env validation - feat(consent): ConsentScript — load third-party only after consent - feat(health): createHealthRoute — Coolify/Docker DB liveness Fixes: - fix(seo): wrap getCachedPayload in try/catch in createManifestHandler (Docker/CI build no longer crashes when DB unreachable) docs: migration.md (20 sections), new env.md/mcp.md, updated agents.md, AGENTS-TEMPLATE.md, forms/hooks/content/seo/consent/deployment/richtext
53 lines
2.4 KiB
TypeScript
53 lines
2.4 KiB
TypeScript
import type { BasePayload } from 'payload';
|
|
import type { ContentOption } from './types.js';
|
|
type CreateMarkdownRendererArgs = {
|
|
/** Pages collection. Default 'pages'. */
|
|
collection?: string;
|
|
/** Archive-backed collections, same value as the plugin option (optional). */
|
|
content?: ContentOption;
|
|
/** Prepend a YAML frontmatter block (title/description/locale). Default true. */
|
|
frontmatter?: boolean;
|
|
/** Field holding the block layout. Default 'layout'. */
|
|
layoutField?: string;
|
|
/** Per-blockType overrides passed to blocksToMarkdown. */
|
|
overrides?: Record<string, (block: Record<string, unknown>) => string>;
|
|
/** SiteSettings global slug. Default 'site-settings'. */
|
|
settingsSlug?: string;
|
|
};
|
|
type MarkdownContext = {
|
|
locale: string;
|
|
payload: BasePayload;
|
|
/** Route slug segments; empty/undefined = locale root (home). */
|
|
slug?: string[];
|
|
};
|
|
/**
|
|
* Returns a function that renders a page (or archive/entry) to clean Markdown —
|
|
* title, meta description, then the block layout via blocksToMarkdown. The
|
|
* point is AI-readability: an agent (Claude's WebFetch, GPT, Perplexity) gets
|
|
* structured Markdown instead of parsing HTML, so it reads the page reliably.
|
|
*
|
|
* Mirrors createPageMetadata: the plugin can't call getPayload, so it returns a
|
|
* function the project invokes from its route handler.
|
|
*
|
|
* // app/md/[locale]/[[...slug]]/route.ts (serves /md/pl/o-nas as text/markdown)
|
|
* import { createMarkdownRenderer, markdownResponse } from '@intecion/ipal-kit'
|
|
* import { getPayload } from 'payload'
|
|
* import config from '@payload-config'
|
|
* const render = createMarkdownRenderer({ content })
|
|
* export const dynamic = 'force-dynamic'
|
|
* export async function GET(_req: Request, { params }: { params: Promise<{ locale: string; slug?: string[] }> }) {
|
|
* const { locale, slug } = await params
|
|
* const md = await render({ payload: await getPayload({ config }), locale, slug })
|
|
* return markdownResponse(md)
|
|
* }
|
|
*
|
|
* Returns null when the route doesn't resolve (so the handler can 404).
|
|
*/
|
|
export declare function createMarkdownRenderer(args?: CreateMarkdownRendererArgs): ({ slug, locale, payload }: MarkdownContext) => Promise<null | string>;
|
|
/**
|
|
* Wraps a Markdown string in a `text/markdown` Response, or a 404 when null.
|
|
* Uses the global Response — no next/server import.
|
|
*/
|
|
export declare function markdownResponse(md: null | string): Response;
|
|
export {};
|