41 lines
1.7 KiB
TypeScript
41 lines
1.7 KiB
TypeScript
import type { BasePayload } from 'payload';
|
|
import type { I18nConfig } from '../i18n/index.js';
|
|
import type { SitemapEntry } from './buildSitemapEntries.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! })
|
|
*/
|
|
export declare function createLlmsTxtRoute(opts: {
|
|
baseUrl: string;
|
|
config: I18nConfig;
|
|
getCachedPayload: () => Promise<BasePayload>;
|
|
pagesSlug?: string;
|
|
settingsSlug?: string;
|
|
}): () => Promise<Response>;
|
|
/**
|
|
* 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 declare function createSitemapRouteHandler(sitemap: () => Promise<SitemapEntry[]>, opts?: {
|
|
cssUrl?: string;
|
|
}): () => Promise<Response>;
|