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
89 lines
3.6 KiB
JavaScript
89 lines
3.6 KiB
JavaScript
import { buildLlmsTxt } from './buildLlmsTxt.js';
|
|
import { buildSitemapXml } from './buildSitemapXml.js';
|
|
/**
|
|
* Ready-made Next route handler for /llms.txt. Replaces the ~60-line try/catch
|
|
* every project was copying. buildLlmsTxt already handles collections without
|
|
* drafts, so no workaround is needed here.
|
|
*
|
|
* // app/llms.txt/route.ts
|
|
* import { createLlmsTxtRoute } from '@intecion/ipal-kit'
|
|
* import { getCachedPayload } from '@/lib/content'
|
|
* import { i18nConfig } from '@/i18n.config'
|
|
* export const dynamic = 'force-dynamic'
|
|
* export const GET = createLlmsTxtRoute({ getCachedPayload, config: i18nConfig,
|
|
* baseUrl: process.env.NEXT_PUBLIC_SERVER_URL! })
|
|
*
|
|
* For the full-content variant, add a second route with `full: true`:
|
|
*
|
|
* // app/llms-full.txt/route.ts
|
|
* export const GET = createLlmsTxtRoute({ getCachedPayload, config: i18nConfig,
|
|
* baseUrl: process.env.NEXT_PUBLIC_SERVER_URL!, full: true })
|
|
*/ export function createLlmsTxtRoute(opts) {
|
|
return async ()=>{
|
|
try {
|
|
const payload = await opts.getCachedPayload();
|
|
const body = await buildLlmsTxt({
|
|
baseUrl: opts.baseUrl,
|
|
config: opts.config,
|
|
full: opts.full,
|
|
pagesSlug: opts.pagesSlug,
|
|
payload,
|
|
settingsSlug: opts.settingsSlug,
|
|
summaryField: opts.summaryField
|
|
});
|
|
return new Response(body, {
|
|
headers: {
|
|
'Content-Type': 'text/plain; charset=utf-8'
|
|
}
|
|
});
|
|
} catch (err) {
|
|
// DB unreachable at build (container) — return a minimal valid file so the
|
|
// route doesn't 500; it fills in at runtime. No per-project try/catch.
|
|
console.warn('[ipal] createLlmsTxtRoute: could not build llms.txt:', err);
|
|
return new Response('# llms.txt\n', {
|
|
headers: {
|
|
'Content-Type': 'text/plain; charset=utf-8'
|
|
}
|
|
});
|
|
}
|
|
};
|
|
}
|
|
/**
|
|
* Ready-made Next route handler for /sitemap.xml with the CSS stylesheet.
|
|
* Replaces the hand-written route in every project. Pass the project's `sitemap`
|
|
* helper (from createContentHelpers) and optionally a cssUrl.
|
|
*
|
|
* // app/sitemap.xml/route.ts
|
|
* import { createSitemapRouteHandler } from '@intecion/ipal-kit'
|
|
* import { sitemap } from '@/lib/content'
|
|
* export const dynamic = 'force-dynamic'
|
|
* export const GET = createSitemapRouteHandler(sitemap, { cssUrl: '/sitemap.css' })
|
|
*
|
|
* Remember: if you use this, DON'T also keep app/sitemap.ts (two sitemaps
|
|
* confuse crawlers).
|
|
*/ export function createSitemapRouteHandler(sitemap, opts = {}) {
|
|
return async ()=>{
|
|
try {
|
|
const entries = await sitemap();
|
|
const xml = buildSitemapXml(entries, {
|
|
cssUrl: opts.cssUrl
|
|
});
|
|
return new Response(xml, {
|
|
headers: {
|
|
'Content-Type': 'application/xml; charset=utf-8'
|
|
}
|
|
});
|
|
} catch (err) {
|
|
console.warn('[ipal] createSitemapRouteHandler: could not build sitemap:', err);
|
|
// Valid empty urlset so the route doesn't 500 during a DB-less build.
|
|
const empty = '<?xml version="1.0" encoding="UTF-8"?>\n' + '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"></urlset>';
|
|
return new Response(empty, {
|
|
headers: {
|
|
'Content-Type': 'application/xml; charset=utf-8'
|
|
}
|
|
});
|
|
}
|
|
};
|
|
}
|
|
|
|
//# sourceMappingURL=routeHandlers.js.map
|