UNPKG

vitepress-plugin-llmstxt

Version:

VitePress plugin to generate llms.txt files automatically

94 lines (91 loc) 2.32 kB
import { SiteConfig, UserConfig } from 'vitepress'; type Any = any; type VitePlugin = NonNullable<NonNullable<UserConfig['vite']>['plugins']>[number]; type VPConfig = SiteConfig; type LlmsPageData = { path: string; url: string; title: string; llmUrl: string; frontmatter: Record<string, Any>; content: string; }; type IndexTOC = boolean | 'only-llms' | 'only-llms-links' | 'only-web' | 'only-web-links'; type LlmsClientPageData = { path: string; url: string; llmUrl: string; }; type LlmsClientConfig = { pageData?: LlmsClientPageData[]; }; type LlmsConfig = { /** * Hostname * * @example 'https://example.org' */ hostname?: string; /** * An array of glob patterns to ignore. * * @example ["**\/guide/api.md"] */ ignore?: string[]; /** * Build `llms.txt` file * * @default true */ llmsFile?: boolean | { /** * Add index table of content in index 'llms.txt' file. * - _'only-llms'_ - Only title with LLMs links * - _'only-web'_ - Only title with web links * - _'only-llms-links'_ - Only LLMs links * - _'only-web-links'_ - Only web links * - _true_ - both * - _false_ - none */ indexTOC: IndexTOC; }; /** * Support dynamic routes * * @default true * @see https://vitepress.dev/guide/routing#dynamic-routes */ dynamicRoutes?: boolean; /** * Build `llms-full.txt` file * * @default true */ llmsFullFile?: boolean; /** * Build `.md` file for each route * * @default true */ mdFiles?: boolean; /** * Watch for changes in pages in development mode * If set to true, llms files will be recompiled on changes in pages * * @default false */ watch?: boolean; /** * Callback for transform each page */ transform?: (data: { page: LlmsPageData; pages: LlmsPageData[]; vpConfig?: VPConfig; utils: { getIndexTOC: (type: IndexTOC) => string; removeFrontmatter: (content: string) => string; }; }) => Promise<LlmsPageData> | LlmsPageData; }; export type { LlmsClientConfig as L, VitePlugin as V, LlmsConfig as a };