import { createMarkdownRenderer, defineLoader, type DefaultTheme, type SiteConfig } from 'vitepress' import { readConfigSchema } from '../../configCheck' import { keyLabel, type ConfigType } from '../../configSchema' /* Build-time data for the config generator (a VitePress data loader): the keys from the reference pages, with their descriptions rendered to HTML, grouped into one section per page in sidebar order. Dev mode reloads it when a watched file changes. Pages and defaults that disagree fail the build in configCheck.ts, not here. */ /** A config key as the generator shows it. */ export interface GeneratorField { path: string /** The key's name as words, e.g. "Show arrows" for `ipp.lightbox.showArrows`. */ label: string type: ConfigType default: unknown /** The allowed values, each with a plain-text label for a select. */ values?: Array<{ value: unknown, label: string }> /** The key's description, as HTML. */ html: string /** The key's section on its reference page. */ link: string /** For a row of a flag table, the label of the key the table is under, e.g. "EXIF". */ group?: string } /** One reference page's keys. */ export interface GeneratorSection { /** The page's sidebar label. */ title: string fields: GeneratorField[] } /** A renamed key, for the paste box to suggest the current name. */ export interface GeneratorRenamedKey { from: string /** The Current key cell from Renamed config keys, as HTML. */ html: string } export interface GeneratorData { sections: GeneratorSection[] renamed: GeneratorRenamedKey[] } declare const data: GeneratorData export { data } /** Every sidebar link with its label, depth first, in sidebar order. */ function sidebarLinks (items: DefaultTheme.SidebarItem[]): Array<{ link: string, text: string }> { return items.flatMap(item => [ ...(item.link && item.text ? [{ link: item.link, text: item.text }] : []), ...sidebarLinks(item.items ?? []) ]) } /** Markdown as plain text, for a `