feat: v1.7.0 — AI-readability suite, form engine & boilerplate helpers
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
This commit is contained in:
Vendored
+55
-3
@@ -1,3 +1,4 @@
|
||||
import { blocksToMarkdown } from '../content/blocksToMarkdown.js';
|
||||
import { buildLocalizedPath } from '../i18n/index.js';
|
||||
/**
|
||||
* Builds the body of /llms.txt — a Markdown file describing the site for AI
|
||||
@@ -27,7 +28,13 @@ import { buildLocalizedPath } from '../i18n/index.js';
|
||||
*
|
||||
* Data comes from the panel (siteName, siteDescription, pages) — nothing
|
||||
* hardcoded. Skips drafts and noindex pages (same as the sitemap).
|
||||
*/ export async function buildLlmsTxt({ baseUrl, config, locale, pagesSlug = 'pages', payload, settingsSlug = 'site-settings' }) {
|
||||
*/ export async function buildLlmsTxt({ baseUrl, config, full = false, layoutField = 'layout', locale, pagesSlug = 'pages', payload, settingsSlug = 'site-settings', summaryField }) {
|
||||
const pickDescription = (raw)=>{
|
||||
if (summaryField && typeof raw[summaryField] === 'string' && raw[summaryField].trim()) {
|
||||
return raw[summaryField].trim();
|
||||
}
|
||||
return typeof raw.meta?.description === 'string' ? raw.meta.description : undefined;
|
||||
};
|
||||
const loc = locale ?? config.defaultLocale;
|
||||
const origin = baseUrl.replace(/\/$/, '');
|
||||
const settings = await payload.findGlobal({
|
||||
@@ -42,9 +49,10 @@ import { buildLocalizedPath } from '../i18n/index.js';
|
||||
// "path cannot be queried: _status" (a real bug report). Draft filtering
|
||||
// happens in memory below, which is safe for every collection. Same as
|
||||
// buildSitemapEntries and generateStaticParams.
|
||||
// Full mode needs depth:1 so block images/relations populate for the Markdown.
|
||||
const result = await payload.find({
|
||||
collection: pagesSlug,
|
||||
depth: 0,
|
||||
depth: full ? 1 : 0,
|
||||
limit: 1000,
|
||||
locale: loc
|
||||
});
|
||||
@@ -55,6 +63,49 @@ import { buildLocalizedPath } from '../i18n/index.js';
|
||||
if (description) {
|
||||
lines.push(`> ${description}`, '');
|
||||
}
|
||||
if (full) {
|
||||
// Full-content: each published page inlined as Markdown under its heading.
|
||||
const sections = [];
|
||||
for (const raw of result.docs){
|
||||
if (raw._status && raw._status !== 'published') {
|
||||
continue;
|
||||
}
|
||||
if (raw.meta?.noindex) {
|
||||
continue;
|
||||
}
|
||||
const title = typeof raw.title === 'string' ? raw.title : undefined;
|
||||
const slug = typeof raw.slug === 'string' ? raw.slug : undefined;
|
||||
if (!title || !slug) {
|
||||
continue;
|
||||
}
|
||||
const path = buildLocalizedPath({
|
||||
config,
|
||||
locale: loc,
|
||||
slugs: {
|
||||
[loc]: slug
|
||||
}
|
||||
});
|
||||
const body = blocksToMarkdown(raw[layoutField]);
|
||||
const desc = pickDescription(raw);
|
||||
const parts = [
|
||||
`## ${title}`
|
||||
];
|
||||
if (path) {
|
||||
parts.push(`${origin}${path}`);
|
||||
}
|
||||
if (desc) {
|
||||
parts.push(`_${desc}_`);
|
||||
}
|
||||
if (body) {
|
||||
parts.push(body);
|
||||
}
|
||||
sections.push(parts.join('\n\n'));
|
||||
}
|
||||
if (sections.length > 0) {
|
||||
lines.push(sections.join('\n\n---\n\n'), '');
|
||||
}
|
||||
return lines.join('\n');
|
||||
}
|
||||
const pageLinks = [];
|
||||
for (const raw of result.docs){
|
||||
if (raw._status && raw._status !== 'published') {
|
||||
@@ -78,7 +129,8 @@ import { buildLocalizedPath } from '../i18n/index.js';
|
||||
if (!path) {
|
||||
continue;
|
||||
}
|
||||
const pageDesc = typeof raw.meta?.description === 'string' ? ` — ${raw.meta.description}` : '';
|
||||
const desc = pickDescription(raw);
|
||||
const pageDesc = desc ? ` — ${desc}` : '';
|
||||
pageLinks.push(`- [${title}](${origin}${path})${pageDesc}`);
|
||||
}
|
||||
if (pageLinks.length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user