46 lines
1.9 KiB
TypeScript
46 lines
1.9 KiB
TypeScript
import type { BasePayload } from 'payload';
|
|
import type { I18nConfig } from '../i18n/index.js';
|
|
type BuildLlmsTxtArgs = {
|
|
/** Absolute site URL (https://…). */
|
|
baseUrl: string;
|
|
config: I18nConfig;
|
|
/** Locale for names/descriptions. Defaults to config.defaultLocale. */
|
|
locale?: string;
|
|
/** Pages collection slug. Defaults to 'pages'. */
|
|
pagesSlug?: string;
|
|
payload: BasePayload;
|
|
/** Site settings global slug. Defaults to 'site-settings'. */
|
|
settingsSlug?: string;
|
|
};
|
|
/**
|
|
* Builds the body of /llms.txt — a Markdown file describing the site for AI
|
|
* agents / LLM crawlers, per the llmstxt.org convention. Mirrors buildRobots /
|
|
* buildSitemapEntries: the plugin already knows the site's name, description,
|
|
* and pages, so it can generate this automatically.
|
|
*
|
|
* Structure (llmstxt.org): H1 site name, a blockquote/summary, then a list of
|
|
* key pages as Markdown links with short descriptions. Agents read this to
|
|
* understand the site quickly without crawling everything.
|
|
*
|
|
* Wire it as a route that returns text/plain:
|
|
*
|
|
* // app/llms.txt/route.ts
|
|
* import { buildLlmsTxt } from '@intecion/ipal-kit'
|
|
* import { getCachedPayload } from '@/lib/content'
|
|
* import { i18nConfig } from '@/i18n.config'
|
|
* export const dynamic = 'force-dynamic'
|
|
* export async function GET() {
|
|
* const body = await buildLlmsTxt({
|
|
* payload: await getCachedPayload(),
|
|
* config: i18nConfig,
|
|
* baseUrl: process.env.NEXT_PUBLIC_SERVER_URL!,
|
|
* })
|
|
* return new Response(body, { headers: { 'Content-Type': 'text/plain; charset=utf-8' } })
|
|
* }
|
|
*
|
|
* Data comes from the panel (siteName, siteDescription, pages) — nothing
|
|
* hardcoded. Skips drafts and noindex pages (same as the sitemap).
|
|
*/
|
|
export declare function buildLlmsTxt({ baseUrl, config, locale, pagesSlug, payload, settingsSlug, }: BuildLlmsTxtArgs): Promise<string>;
|
|
export {};
|