/** * Docs page resolution: everything `DocsShell` needs to know about the page * being read, derived in one place from the content index, the version manifest * and the URL. * * Pure and framework-agnostic, so each rule is a field with a test rather than * a derivation whose only test surface is a rendered tree. The view returns * data, never formatted strings: locale formatting and copy stay in the * component that renders them. */ import type { DocsContentItem } from './content.js'; import { type Breadcrumb, type NavGroup, type NavItem } from './nav.js'; import { type ResolvedVersion } from './version.js'; /** The page's build-time headings, as extracted into the content index. */ type PageToc = NonNullable; /** One declared version, and where switching to it should take the reader. */ export type VersionLink = { id: string; label: string; /** This page under that version, or its landing when the page isn't there. */ href: string; /** Whether this is the version being read. */ active: boolean; }; /** Everything `DocsShell` renders about the current page. */ export type DocsPageView = { /** The current path, trailing slash stripped. Match content against this. */ pathname: string; /** * The version owning the page, falling back to the current version off the * docs tree (e.g. a `page` layout). `undefined` on an unversioned site. */ activeVersion: ResolvedVersion | undefined; /** {@link activeVersion}'s id, for scoping search. */ activeVersionId: string | undefined; /** The current version, for the archived-version banner's "latest" link. */ currentVersion: ResolvedVersion | undefined; /** Whether the page belongs to an archived (frozen) version. */ isArchived: boolean; /** The content index scoped to {@link activeVersion}. */ scopedContent: DocsContentItem[]; /** Sidebar nav built from {@link scopedContent}. */ nav: NavGroup[]; /** The scoped content entry for this route, if the page is a doc page. */ entry: DocsContentItem | undefined; /** "Edit this page" target. Absent without an edit base, or when archived. */ editHref: string | undefined; /** The page's last commit date, unformatted. Absent if missing or unparseable. */ lastUpdated?: Date; /** Estimated reading time in whole minutes, uncopied. */ readingMinutes?: number; /** Previous page in sidebar reading order. */ prev: NavItem | undefined; /** Next page in sidebar reading order. */ next: NavItem | undefined; /** The page's nav title, falling back to the site title off the nav tree. */ title: string; /** * Breadcrumb trail: group steps (with a jump URL to the group's first page), * then the current page as a title-only final crumb. No component types * here — the shell maps this onto its `Crumb` shape. */ breadcrumbs: Breadcrumb[]; /** The page's server-rendered TOC, from {@link entry}. */ toc: PageToc; /** * Every declared version with the URL that keeps the reader on this page, in * switcher order. Empty on an unversioned site, so the switcher and the * archived-version banner both render off this one list. */ versionLinks: VersionLink[]; }; /** * Resolve the page being read. `pathname` is taken raw (normalized here, so the * caller has one fewer place to remember) and every field is derived from the * same normalized path and the same scoped content, so the sidebar, prev/next, * breadcrumbs and TOC can never disagree about which page or version is active. */ export declare function resolveDocsPage(input: { content: DocsContentItem[]; versions: ResolvedVersion[]; pathname: string; editUrl?: string; siteTitle: string; }): DocsPageView; export {};