@signalwire/docusaurus-plugin-llms-txt
Version:
Generate Markdown versions of Docusaurus HTML pages and an llms.txt index file
143 lines • 6.15 kB
TypeScript
/**
* Public type definitions for docusaurus-plugin-llms-txt
* Only exports types that plugin users need to configure and use the plugin
*/
import type { ReportingSeverity } from '@docusaurus/types';
import { Joi } from '@docusaurus/utils-validation';
import type { Options as RemarkGfmOptions } from 'remark-gfm';
import type { Options as RemarkStringifyOptions } from 'remark-stringify';
import type { Plugin, Settings } from 'unified';
/**
* Depth levels for document categorization
*/
export type Depth = 1 | 2 | 3 | 4 | 5;
/**
* Configuration for processing specific route paths
*/
export interface RouteRule {
/** Route pattern to match (glob pattern, no file extension) */
readonly route: string;
/** Override depth for this path */
readonly depth?: Depth;
/** Override content selectors for this path */
readonly contentSelectors?: readonly string[];
/** Category name override for this path */
readonly categoryName?: string;
/** Path-specific ordering of subcategories (glob patterns) */
readonly includeOrder?: readonly string[];
}
/**
* Optional link for inclusion in llms.txt
*/
export interface OptionalLink {
/** Link title */
readonly title: string;
/** Link URL */
readonly url: string;
/** Optional description */
readonly description?: string;
}
/**
* Standard unified plugin input types
* Follows unified.js conventions: function, [function, options], [function, options, settings]
*/
export type PluginInput = Plugin<unknown[], any, unknown> | [Plugin<unknown[], any, unknown>, unknown?, Settings?];
/**
* Content processing options that affect individual markdown file generation
*/
export interface ContentOptions {
/** Whether to generate individual markdown files (default: true) */
readonly enableMarkdownFiles?: boolean;
/** Whether to generate llms-full.txt with complete content (default: false) */
readonly enableLlmsFullTxt?: boolean;
/** Whether to use relative paths in links (default: true) */
readonly relativePaths?: boolean;
/** Include blog posts (default: false) */
readonly includeBlog?: boolean;
/** Include pages (default: false) */
readonly includePages?: boolean;
/** Include docs (default: true) */
readonly includeDocs?: boolean;
/** Include versioned docs in addition to current version (default: true) */
readonly includeVersionedDocs?: boolean;
/** Include generated category index pages (default: true) */
readonly includeGeneratedIndex?: boolean;
/** Glob patterns to exclude from processing */
readonly excludeRoutes?: readonly string[];
/** CSS selectors for content extraction */
readonly contentSelectors?: readonly string[];
/** Route-specific processing rules */
readonly routeRules?: readonly RouteRule[];
/** Remark stringify options for markdown generation */
readonly remarkStringify?: Readonly<RemarkStringifyOptions>;
/** Remark GFM options for markdown processing */
readonly remarkGfm?: boolean | Readonly<RemarkGfmOptions>;
/** Whether to process tables with rehype (default: true) */
readonly rehypeProcessTables?: boolean;
/** Custom rehype plugins run before built-in processing */
readonly beforeDefaultRehypePlugins?: readonly PluginInput[];
/** Custom rehype plugins run after built-in processing */
readonly rehypePlugins?: readonly PluginInput[];
/** Custom remark plugins run before built-in processing */
readonly beforeDefaultRemarkPlugins?: readonly PluginInput[];
/** Custom remark plugins run after built-in processing */
readonly remarkPlugins?: readonly PluginInput[];
}
/**
* Main plugin configuration options
*/
export interface PluginOptions {
/** Plugin instance ID (injected by Docusaurus) */
readonly id?: string;
/** Content processing options (affects individual file generation) */
readonly content?: ContentOptions;
/** Categorization depth for document tree (default: 1) */
readonly depth?: Depth;
/** Whether to include descriptions in llms.txt links (default: true) */
readonly enableDescriptions?: boolean;
/** Site title for llms.txt header */
readonly siteTitle?: string;
/** Site description for llms.txt header */
readonly siteDescription?: string;
/** Additional links to include in llms.txt */
readonly optionalLinks?: readonly OptionalLink[];
/** Global ordering of categories (glob patterns) */
readonly includeOrder?: readonly string[];
/** Whether to run during postBuild phase (default: true) */
readonly runOnPostBuild?: boolean;
/** How to handle route processing failures: 'ignore' | 'log' | 'warn' | 'throw' (default: 'warn') */
readonly onRouteError?: ReportingSeverity;
/** Operational logging level: 0=quiet, 1=normal, 2=verbose, 3=debug (default: 1) */
readonly logLevel?: 0 | 1 | 2 | 3;
}
/**
* Re-export error types from the main errors module to avoid duplication
*/
export type { PluginError, PluginConfigError, PluginValidationError, } from '../errors';
export { isPluginError } from '../errors';
/**
* Logger interface for plugin operations
* Separated concerns: onRouteError for error handling, logLevel for operational verbosity
*/
export interface Logger {
/** Report a route processing error with configurable severity */
reportRouteError: (_msg: string) => void;
/** Log errors (always shown) */
error: (_msg: string) => void;
/** Log warnings (level 1+) */
warn: (_msg: string) => void;
/** Log info messages (level 2+) */
info: (_msg: string) => void;
/** Log debug messages (level 3+) */
debug: (_msg: string) => void;
/** Log success messages (level 1+) */
success: (_msg: string) => void;
/** Core reporting method for specific severity */
report: (_severity: ReportingSeverity, _msg: string) => void;
}
/**
* Joi schema for plugin options validation
* @internal - This is used by Docusaurus framework for options validation
*/
export declare const pluginOptionsSchema: Joi.ObjectSchema<PluginOptions>;
//# sourceMappingURL=public.d.ts.map