/** * Pure, framework-free navigation for the docs sidebar. Given the front-matter of every page in * one language, {@link buildNavTree} assembles the **tabs -> groups -> ordered pages** tree the * sidebar renders; {@link flattenNav} linearises it into reading order (for prev/next); * {@link adjacentFor} and {@link breadcrumbFor} derive a single page's prev/next and breadcrumb. * * This is the structural piece a blog does not need (a blog is a flat, date-sorted list). Kept * fs-free (no `node:fs`, no `next`/`react` import) so it is trivially unit-testable and can be * shared with the React components; the on-disk layout is walked by the `Docs` reader, which * feeds this the parsed metadata. */ import type { Adjacent, Breadcrumb, DocMeta, NavConfigEntry, NavItem, NavTree } from "./types.js"; /** URL/ordering inputs {@link buildNavTree} needs beyond the page metadata itself. */ export interface NavBuildOptions { /** The section base path (e.g. `/docs`), passed through to `localePath`. */ basePath?: string | undefined; /** The default locale code (served unprefixed unless `prefixDefaultLocale`). */ defaultLocale: string; /** * The language this tree is being built for, which is what a per-locale tab/group label is * resolved against. Defaults to `defaultLocale` - so an existing caller that omits it keeps * getting the default-locale labels it always got. */ lang?: string | undefined; /** When `true`, the default locale is URL-prefixed too. */ prefixDefaultLocale?: boolean | undefined; /** When `false`, nav `href`s omit the trailing slash. Defaults to `true`; see `SiteConfig.trailingSlash`. */ trailingSlash?: boolean | undefined; /** Optional tab display order + labels. */ tabs?: NavConfigEntry[] | undefined; /** Optional group display order + labels. */ groups?: NavConfigEntry[] | undefined; } /** * Assembles the sidebar navigation tree for one language from its pages' front-matter. * * Pages are bucketed by `tab` (a single implicit `""` tab when none is set - `multiTab` is then * `false` so the frontend hides the tab bar) and then by `group` (a `""` bucket for ungrouped * pages). Tabs and groups are ordered by the `tabs`/`groups` config first, then by their pages' * minimum `order`, then first-seen; pages within a group are ordered by `order` then title. * `hidden` pages are excluded. * * @param metas - every (non-hidden and hidden) page's front-matter for one language; `hidden` * pages are filtered out here. * @param opts - URL options plus the optional tab/group ordering config. * @returns the ordered {@link NavTree}. */ export declare function buildNavTree(metas: DocMeta[], opts: NavBuildOptions): NavTree; /** * Linearises a nav tree into its reading order: every page, tabs then groups then items, in the * order the sidebar shows them. The basis for prev/next. * * @param tree - the navigation tree. * @returns the flattened list of nav items. */ export declare function flattenNav(tree: NavTree): NavItem[]; /** * Finds the pages immediately before and after `slug` in the flattened reading order. Prev/next * cross group and tab boundaries (matching common docs UIs); either side is `undefined` at the * ends, and an unknown slug yields an empty result. * * @param slug - the current page slug. * @param flat - the flattened nav items (from {@link flattenNav}). * @returns the previous and next pages, if any. */ export declare function adjacentFor(slug: string, flat: NavItem[]): Adjacent; /** * Builds a page's breadcrumb (`[tab?, group?, page]`) from the nav tree. Empty tab/group ids * (the implicit tab / ungrouped bucket) contribute no segment. * * @param slug - the page slug. * @param tree - the navigation tree the page lives in. * @returns the breadcrumb, or `undefined` when the slug is not in the tree (e.g. a hidden page). */ export declare function breadcrumbFor(slug: string, tree: NavTree): Breadcrumb | undefined;