import { d as ValidatorContext, i as CollectionDef, l as ContentValidator, m as ValidationResult, o as InferCollectionData, p as ValidationIssue, t as ContentLayerConfig } from "./content-config-CJROdGFz.mjs"; import { r as MarkdownConfig, t as Heading } from "./heading-CIGVDIkM.mjs"; import { ZodType } from "zod"; //#region src/convert.d.ts type ConvertOptions = { markdown?: MarkdownConfig; /** * Absolute or project-relative source path for the markdown being converted. * Provide this when the markdown references local images so Pagesmith can * resolve refs from the markdown file and fill intrinsic dimensions. */ sourcePath?: string; /** * Allowed root directory for relative local image refs. Defaults to the * markdown file's own directory when `sourcePath` is provided. Set this when * you want `convert()` to allow refs that move outside the file directory but * still stay inside a broader content root, matching `entry.render()`. */ assetRoot?: string; }; type ConvertResult = { html: string; headings: Heading[]; /** @deprecated Use `headings` for consistency with `processMarkdown()` and `entry.render()`. */ toc: Heading[]; frontmatter: Record; }; declare function convert(input: string, options?: ConvertOptions): Promise; //#endregion //#region src/entry.d.ts type RenderedContent = { /** Processed HTML */html: string; /** Extracted headings for TOC */ headings: Heading[]; /** Estimated read time in minutes */ readTime: number; }; declare class ContentEntry> { /** URL-friendly identifier */ readonly slug: string; /** Collection this entry belongs to */ readonly collection: string; /** Absolute path to source file */ readonly filePath: string; /** Validated data (frontmatter or parsed data) */ readonly data: T; /** Raw body content (markdown only) */ readonly rawContent?: string; /** Cached render result */ private _rendered?; /** Markdown config for rendering */ private _markdownConfig; /** Allowed root for resolving relative local assets referenced by this entry. */ private _assetRoot?; constructor(slug: string, collection: string, filePath: string, data: T, rawContent: string | undefined, markdownConfig: MarkdownConfig, assetRoot?: string); /** Render the entry content to HTML. Cached after first call. */ render(options?: { force?: boolean; }): Promise; /** Clear cached render result. */ clearRenderCache(): void; } //#endregion //#region src/validation/code-block-validator.d.ts declare const codeBlockValidator: ContentValidator; //#endregion //#region src/validation/heading-validator.d.ts declare const headingValidator: ContentValidator; //#endregion //#region src/validation/image-structure-validator.d.ts /** * Validate image HTML structure in a single markdown entry. Exported so * callers that already parsed HTML themselves can reuse the rules. */ declare function validateImageHtml(html: string, baseLine?: number): ValidationIssue[]; declare const imageStructureValidator: ContentValidator; //#endregion //#region src/validation/link-validator.d.ts type LinkValidatorOptions = { /** * URL prefixes or glob-like patterns to skip during internal/external link * validation. Useful for known-dynamic routes or generated links. */ skipPatterns?: string[]; /** * Absolute root directory used to resolve site-absolute URLs (paths that * start with `/`). When set, `/guide/foo` resolves to * `/guide/foo`. When unset, absolute paths cannot be verified and * are skipped. */ rootDir?: string; /** * Site base path prefix (e.g. `/pagesmith`). When provided, it is stripped * from site-absolute URLs before resolving against `rootDir`. */ basePath?: string; /** * Extra filesystem roots used to resolve site-absolute URLs. Each entry * maps a URL prefix to a directory. Any URL starting with `prefix` is * checked for existence under `dir` before the link is flagged as broken. * * Typical use: register `publicDir` at prefix `/`, and each docs * `assets[]` entry at its configured prefix. */ additionalRoots?: Array<{ prefix: string; dir: string; }>; /** * Custom predicate for internal link targets. When provided and it returns * false, an error is reported. Invoked with the cleaned URL (no query / * fragment) and the resolved filesystem path. */ allowInternalTarget?: (href: string, resolvedPath: string) => boolean; /** * When `true`, non-image internal links that do not resolve to a markdown * file (`.md`, `.mdx`, or any `README.md` / `index.md` in a directory) are * flagged as errors. Enforces the "internal links must be to other local * markdown" rule while still allowing image links and links to static * assets (which are reported through the image validator's channels). */ internalLinksMustBeMarkdown?: boolean; /** * When `true`, every internal page link must be authored as a *relative* * path ending in `.md` or `.mdx` (for example `./relative/README.md`, * `./foo.md`, `../sibling/index.md`). Bare forms (`./foo`, `./foo/`) and * site-absolute URLs (`/guide/foo`) are rejected so the source form is * always an unambiguous, grep-able path to a real file on disk. * * Images, fragment-only hrefs, `mailto:`/`tel:`, external URLs, and any * URL matching `skipPatterns` / resolving under an `additionalRoots` * asset tree are exempt. The docs preset turns this on by default; the * core default stays `false` so third-party consumers are not broken. */ requireCanonicalInternalLinks?: boolean; /** * When `true`, every image must carry non-empty alt text. Default: `true`. * Set to `false` to treat missing alt only as a warning (via the existing * accessibility channel). */ requireAltText?: boolean; /** * When `true`, fail if the markdown contains a raw `` HTML tag. * Authors should use the `![]()` Markdown syntax (or a MDX component) so * the image pipeline can rewrite URLs, hash filenames, and emit * theme-aware variants. Default: `true`. */ forbidHtmlImgTag?: boolean; /** * When `true`, adjacent image references with `-light` / `-dark` filename * suffixes must appear as a matched pair. Missing or mis-ordered pairs * become errors so authors always ship both theme variants. Images with a * `.invert` class-style suffix are exempt and accepted as single entries. * Default: `true`. */ requireThemeVariantPairs?: boolean; /** * When `true`, external (http/https) URLs are fetched and a non-2xx or * failing response becomes a warning/error. Off by default so local * validation stays fast and offline-friendly. */ checkExternalReachability?: boolean; /** * Severity used when an external URL is unreachable (fetch fails or * response status is not `2xx`). Default: `'warn'`. */ unreachableSeverity?: "warn" | "error"; /** Request timeout (ms) when fetching external URLs. Default: 10000. */ fetchTimeoutMs?: number; /** * Upper bound on the number of concurrent external URL requests from a * single validator invocation. Default: 8. */ fetchConcurrency?: number; /** * Optional fetch implementation. Defaults to the global `fetch`. Accepts * `HEAD` requests and falls back to `GET` automatically when `HEAD` fails. */ fetchImpl?: typeof fetch; }; declare function createLinkValidator(options?: LinkValidatorOptions): ContentValidator; declare const linkValidator: ContentValidator; //#endregion //#region src/validation/runner.d.ts /** The built-in validators for markdown content. */ declare const builtinMarkdownValidators: ContentValidator[]; /** Run all validators on a single content entry. */ declare function runValidators(ctx: ValidatorContext, validators: ContentValidator[]): Promise; //#endregion //#region src/validation/content-validator.d.ts type ValidateContentOptions = { /** * Absolute path to the content directory. All markdown files below this * directory will be walked. */ contentDir: string; /** * Glob patterns (relative to `contentDir`) used to locate markdown files. * Default: `['**\/*.md', '**\/*.mdx']`. */ include?: string[]; /** Glob patterns to exclude. Default: `['**\/node_modules/**']`. */ exclude?: string[]; /** * Optional Zod schema to validate the frontmatter of every file. Applies * uniformly to every entry. Use {@link resolveFrontmatterSchema} when the * schema differs by collection / file location. * * When omitted, only structural validators (links, images, headings, code * blocks) run and frontmatter is accepted as-is. */ frontmatterSchema?: ZodType; /** * Per-file frontmatter schema lookup. Invoked once per markdown file with * the absolute path; return `undefined` to skip schema validation for that * file (structural validators still run). Takes precedence over * {@link frontmatterSchema}. * * Typical use: pair with `loadContentSchemaMap` to validate each file * against the schema declared in the project's `content.config.ts`. */ resolveFrontmatterSchema?: (filePath: string) => ZodType | undefined; /** * Forwarded to {@link createLinkValidator}. Useful for site-absolute links * (set `rootDir` + `basePath`), restricting allowed internal targets, and * opting into external URL reachability checks. */ linkValidator?: LinkValidatorOptions; /** * Additional custom validators to run on every entry. They receive the * parsed MDAST alongside the raw content and frontmatter. */ extraValidators?: ContentValidator[]; /** * Whether to include the built-in heading / code-block validators. * Default: `true`. */ includeStructuralValidators?: boolean; /** * Collection name recorded on results. Default: `'content'`. */ collectionName?: string; }; type ContentFileResult = { /** Absolute source file path. */filePath: string; /** Path relative to `contentDir`. */ relativePath: string; /** Human-readable slug derived from the file path. */ slug: string; /** Issues produced by schema + structural validators. */ issues: ValidationIssue[]; }; type ValidateContentSummary = { collection: string; contentDir: string; fileCount: number; errors: number; warnings: number; results: ContentFileResult[]; }; /** * Validate every markdown file in a content directory. * * The returned summary aggregates schema + content validator issues and * includes totals so CLIs can trivially produce pass/fail exit codes. */ declare function validateContent(options: ValidateContentOptions): Promise; /** * Render a human-readable report from a {@link ValidateContentSummary}. * * Designed for CLIs: the returned string is suitable for `console.log` * directly. Empty when there are no issues. */ declare function formatContentValidationReport(summary: ValidateContentSummary, options?: { showClean?: boolean; }): string; //#endregion //#region src/validation/load-content-config.d.ts type DiscoveredContentConfig = { /** Absolute path of the resolved config module. */filePath: string; /** Project root the config lives under (used to resolve `directory` paths). */ projectRoot: string; }; /** * Walk the candidate directories looking for the first `content.config.*` * file. Returns `null` when none is found (auto-load is opt-out). */ declare function discoverContentConfig(searchDirs: readonly string[], basenames?: readonly string[]): DiscoveredContentConfig | null; /** * Minimal shape we need from a collection definition. Mirrors the public * `CollectionDef` from `defineCollection` so we stay schema-agnostic and do * not import the full type graph here. */ type LoadedCollection = { /** Loader identifier — `'markdown'` is the only kind that participates in markdown validation. */loader: string | { kind?: string; }; /** Directory relative to the project root. */ directory: string; /** Include glob patterns relative to `directory`. */ include?: string[]; /** Exclude glob patterns relative to `directory`. */ exclude?: string[]; /** Optional Zod schema applied to each entry in this collection. */ schema?: ZodType; }; type LoadedCollections = Record; /** * Dynamically import the discovered config and extract the collections map. * * Node 24's automatic TypeScript type-stripping handles `.ts` files * transparently. Files that import other relative TS modules also resolve * because Node uses the file:// URL of the importer. */ declare function loadContentCollections(configPath: string): Promise; type FileSchemaEntry = { collectionName: string; schema?: ZodType; loaderKind: string; }; /** * Walk every collection's `directory + include` patterns and build a lookup * from absolute file path to the collection (and its schema) that owns it. * * Earlier collections in declaration order win when a file matches more than * one collection — this lets users put a more-specific collection first to * intentionally override the broader one. */ declare function buildFileSchemaMap(collections: LoadedCollections, projectRoot: string): Promise>; /** * High-level helper: discover, load, and build the per-file schema lookup * in one call. Returns `null` when no config is found (the validator falls * back to schema-less structural validation). */ declare function loadContentSchemaMap(searchDirs: readonly string[]): Promise<{ configPath: string; projectRoot: string; collections: LoadedCollections; schemaByFile: Map; } | null>; //#endregion //#region src/content-layer.d.ts type WatchEvent = { collection: string; event: string; filename: string | null; }; type WatchHandle = { close(): void; }; type WatchCallback = (event: WatchEvent) => void; /** Typed content layer that preserves collection schema types. */ type TypedContentLayer> = ContentLayer & { getCollection(name: K): Promise>[]>; getEntry(collection: K, slug: string): Promise> | undefined>; }; interface ContentLayer { /** Get all entries in a collection. */ getCollection(name: string): Promise; /** Get a single entry by collection name and slug. */ getEntry(collection: string, slug: string): Promise; /** Convert raw markdown to HTML (no collection, no validation). */ convert(markdown: string, options?: LayerConvertOptions): Promise; /** Invalidate a single entry's cache. */ invalidate(collection: string, slug: string): Promise; /** Invalidate an entire collection's cache. */ invalidateCollection(collection: string): Promise; /** Invalidate all cached data. */ invalidateAll(): void; /** Validate all entries in a collection (or all collections). */ validate(collection?: string): Promise; /** Get the names of all configured collections. */ getCollectionNames(): string[]; /** Get the definition of a collection. */ getCollectionDef(name: string): CollectionDef | undefined; /** Get all collection definitions. */ getCollections(): Record; /** Invalidate entries in a collection that match a predicate. Returns count of invalidated entries. */ invalidateWhere(collection: string, predicate: (entry: ContentEntry) => boolean): Promise; /** Watch collection directories for changes. Returns a handle to stop watching. */ watch(callback: WatchCallback): WatchHandle; /** Get cache statistics for debugging and monitoring. */ getCacheStats(): { collections: number; entries: Record; totalEntries: number; }; } type LayerConvertOptions = { markdown?: MarkdownConfig; /** * Absolute or project-relative source path for the markdown being converted. * Provide this when the markdown references local images so `convert()` can * resolve refs from the markdown file and fill intrinsic dimensions. */ sourcePath?: string; /** * Allowed root directory for relative local image refs. Defaults to the * markdown file's own directory when `sourcePath` is provided. Set this when * you want `layer.convert()` to allow refs that move outside the file * directory but still stay inside a broader content root, matching * `entry.render()`. */ assetRoot?: string; }; /** Create a new content layer from a configuration. */ declare function createContentLayer>(config: ContentLayerConfig & { collections: T; }): TypedContentLayer; declare function createContentLayer(config: ContentLayerConfig): ContentLayer; //#endregion export { ContentEntry as A, LinkValidatorOptions as C, validateImageHtml as D, imageStructureValidator as E, ConvertOptions as M, ConvertResult as N, headingValidator as O, convert as P, runValidators as S, linkValidator as T, ValidateContentOptions as _, WatchEvent as a, validateContent as b, DiscoveredContentConfig as c, LoadedCollections as d, buildFileSchemaMap as f, ContentFileResult as g, loadContentSchemaMap as h, WatchCallback as i, RenderedContent as j, codeBlockValidator as k, FileSchemaEntry as l, loadContentCollections as m, LayerConvertOptions as n, WatchHandle as o, discoverContentConfig as p, TypedContentLayer as r, createContentLayer as s, ContentLayer as t, LoadedCollection as u, ValidateContentSummary as v, createLinkValidator as w, builtinMarkdownValidators as x, formatContentValidationReport as y }; //# sourceMappingURL=content-layer-DtDJaHHK.d.mts.map