import Link from "next/link"; import type { Block, Inline, ManualPage } from "@/lib/manual"; import { MANUAL_REVIEWED, readMinutes } from "@/lib/manual"; import { SITE_ORIGIN, sectionTitle } from "@/lib/manual-links"; /* Renders one manual page. `base` is where the manual lives on this surface: "/docs" on the * website, "/app/help" inside the app. Manual links are rewritten to it; inside the app, links to * website-only pages go to the public site, because the Community edition has no website. */ export type ManualBase = "/docs" | "/app/help"; function Href({ href, base, children }: { href: string; base: ManualBase; children: React.ReactNode }) { if (/^(https?:|mailto:)/.test(href)) return {children}; if (href.startsWith("#")) return {children}; if (href === "/docs" || href.startsWith("/docs/") || href.startsWith("/docs#")) return {children}; if (base === "/app/help") return {children}; return {children}; } export function Inl({ c, base }: { c: Inline[]; base: ManualBase }) { return ( <> {c.map((x, i) => typeof x === "string" ? {x} : x.t === "code" ? {x.v} : x.t === "b" ? : , )} ); } function BlockView({ b, base }: { b: Block; base: ManualBase }) { switch (b.t) { case "p": return

; case "ul": return ; case "ol": return
    {b.items.map((it, i) =>
  1. )}
; case "code": return
{b.v}
; case "callout": return
{b.label}
; case "table": return (
{b.head.map((h, i) => )}{b.rows.map((r, i) => {r.map((c, j) => )})}
); case "h2": return null; } } /** The page body, grouped into one
per heading so the rail can follow along. */ export function ManualBody({ blocks, base }: { blocks: Block[]; base: ManualBase }) { const groups: { h?: Extract; body: Block[] }[] = [{ body: [] }]; for (const b of blocks) { if (b.t === "h2") groups.push({ h: b, body: [] }); else groups[groups.length - 1].body.push(b); } return ( <> {groups.map((g, i) => g.h ? (

{g.h.n}{g.h.text}

{g.body.map((b, j) => )}
) : g.body.length ?
{g.body.map((b, j) => )}
: null, )} ); } /** A whole article: breadcrumb, title, summary, the facts strip, the body, and previous and next. */ export function ManualArticle({ page, base, prev, next }: { page: ManualPage; base: ManualBase; prev?: ManualPage; next?: ManualPage }) { const release = process.env.NEXT_PUBLIC_RELEASE; return (
Docs{sectionTitle(page.section)}

{page.title}

{page.summary &&

{page.summary}

}
{page.screen &&
Screen{page.screen}
} {page.role &&
Who{page.role}
}
Read time{readMinutes(page.words)} min
Checked against{release ? `release ${release}` : MANUAL_REVIEWED}
); }