/** * Utility functions for the docusaurus-plugin-llms plugin */ import { PluginOptions } from './types'; export * from './guards'; export * from './numberPrefix'; export * from './logger'; export * from './files'; export * from './content'; export * from './images'; /** * Normalizes a file path by converting all backslashes to forward slashes. * This ensures consistent path handling across Windows and Unix systems. * * @param filePath - The file path to normalize * @returns The normalized path with forward slashes * @throws ValidationError if filePath is not a string */ export declare function normalizePath(filePath: string): string; /** * Validates that a file path does not exceed the platform-specific maximum length * @param filePath - The file path to validate * @returns True if the path is within limits, false otherwise */ export declare function validatePathLength(filePath: string): boolean; /** * Shortens a file path by creating a hash-based filename if the path is too long * @param fullPath - The full file path that may be too long * @param outputDir - The output directory base path * @param relativePath - The relative path from the output directory * @returns A shortened path if necessary, or the original path if it's within limits */ export declare function shortenPathIfNeeded(fullPath: string, outputDir: string, relativePath: string): string; /** * Check if a file should be ignored based on glob patterns * Matches against both site-relative and docs-relative paths * @param filePath - Path to the file * @param baseDir - Base directory (site root) for relative paths * @param ignorePatterns - Glob patterns for files to ignore * @param docsDir - Docs directory name (e.g., 'docs') * @returns Whether the file should be ignored */ export declare function shouldIgnoreFile(filePath: string, baseDir: string, ignorePatterns: string[], docsDir?: string): boolean; /** * Recursively reads all Markdown files in a directory * @param dir - Directory to scan * @param baseDir - Base directory (site root) for relative paths * @param ignorePatterns - Glob patterns for files to ignore * @param docsDir - Docs directory name (e.g., 'docs') * @param warnOnIgnoredFiles - Whether to warn about ignored files * @param visitedPaths - Set of already visited real paths to detect symlink loops (internal use) * @returns Array of file paths */ export declare function readMarkdownFiles(dir: string, baseDir: string, ignorePatterns?: string[], docsDir?: string, warnOnIgnoredFiles?: boolean, visitedPaths?: Set): Promise; /** * Apply path transformations according to configuration * @param urlPath - Original URL path * @param pathTransformation - Path transformation configuration * @returns Transformed URL path */ export declare function applyPathTransformations(urlPath: string, pathTransformation?: PluginOptions['pathTransformation']): string; /** * Sanitize a string to create a safe filename * @param input - Input string (typically a title) * @param fallback - Fallback string if input becomes empty after sanitization * @returns Sanitized filename (without extension) * @throws ValidationError if input or fallback are not strings */ export declare function sanitizeForFilename(input: string, fallback?: string, options?: { preserveUnicode?: boolean; preserveCase?: boolean; }): string; /** * Ensure a unique identifier from a set of used identifiers * @param baseIdentifier - Base identifier to make unique * @param usedIdentifiers - Set of already used identifiers * @param suffix - Suffix pattern (default: number in parentheses) * @returns Unique identifier * @throws ValidationError if baseIdentifier is not a string or usedIdentifiers is not a Set */ export declare function ensureUniqueIdentifier(baseIdentifier: string, usedIdentifiers: Set, suffix?: (counter: number, base: string) => string): string; /** * Join a route path onto `siteUrl`, preserving the baseUrl pathname that * `siteUrl` already carries (e.g. `https://host/docs`). The route is prepended * with the baseUrl only when it doesn't already start with it, so the baseUrl is * neither dropped nor duplicated regardless of whether Docusaurus routes include * it. `routePath` is used as-is (already URL-encoded by the caller when needed). * * @param siteUrl - Site URL including baseUrl pathname * @param routePath - Route path, with or without a leading slash / baseUrl prefix * @returns Absolute URL string */ export declare function joinSiteUrl(siteUrl: string, routePath: string): string;