/** * Pure helpers for version-switch fallback resolution. * * The version switcher swaps a version's route prefix onto the current * pathname. When the resulting page doesn't exist in the target version's * content tree, these helpers resolve the nearest existing ancestor instead * so the switch never lands on a 404. * * Kept free of React / Next.js imports so the logic can be unit tested from * dist with `node --test` (matching `internal/sidebar-tree.ts`). */ /** * The set of paths that exist for one version, expressed relative to the * version's route prefix (e.g. `/docs/getting-started`, never * `/v5/docs/getting-started`). */ export interface GeistdocsVersionPaths { /** * Where to land when neither the switched path nor any of its ancestors * exist in the target version — typically the version's docs root. */ fallbackPath?: string; paths: readonly string[]; } /** Ensure a leading slash and strip trailing slashes; `""` becomes `/`. */ export declare const normalizeVersionPath: (path: string) => string; /** * Strip a version's public route prefix from a path when present. Loader URLs * may already include the prefix (`baseUrl: "/v1/docs"`) or not * (`baseUrl: "/docs"` with the prefix applied at render time), so this * normalizes both shapes to prefix-relative paths. */ export declare const stripVersionRoutePrefix: (path: string, routePrefix?: string) => string; export interface ResolveVersionSwitchPathOptions { /** The prefix-relative path being switched to. */ candidate: string; /** Landing path when no ancestor of the candidate exists. */ fallbackPath?: string; /** Prefix-relative paths that exist in the target version. */ paths: readonly string[]; } /** * Resolve the best existing path for a version switch: the candidate itself * when it exists, otherwise its nearest existing ancestor, otherwise * `fallbackPath`. Returns `null` when nothing matches, in which case callers * should keep the plain prefix-swap behavior. */ export declare const resolveVersionSwitchPath: ({ candidate, fallbackPath, paths, }: ResolveVersionSwitchPathOptions) => string | null; //# sourceMappingURL=version-paths.d.ts.map