master @ 26 LINES
[ HISTORY ] [ UP ]
┌─ ASTRO ────────────────────────────────────────────────────────────────────┐
│ --- │
│ // Dual-rendered contents block. Rows carry links, so they render as │
│ // per-row Pres (like Tree) rather than through Frame. │
│ import Pre from "../Pre/Pre.astro"; │
│ import Frame from "../Frame/Frame.astro"; │
│ import { rule, row2 } from "../../lib/ascii"; │
│ import { FRAME_W, MOBILE_FRAME_W } from "../../lib/config"; │
│ import { layoutToc, type Props, type TocRow } from "./TableOfContents"; │
│ import "./TableOfContents.scss"; │
│ │
│ const { headings, maxDepth = 3 } = Astro.props as Props; │
│ const wide = layoutToc(headings, FRAME_W, maxDepth); │
│ const narrow = layoutToc(headings, MOBILE_FRAME_W, maxDepth); │
│ │
│ const row = (r: TocRow, variant: string) => ({ r, variant }); │
│ const rows = [...wide.map((r) => row(r, "frame-wide")), ...narrow.map((r) => row(r │
│ , "frame-narrow"))]; │
│ --- │
│ {wide.length > 0 && ( │
│ <nav class="toc" aria-label="Contents"> │
│ <Frame build={(w) => [row2("CONTENTS", `${wide.length} SECTIONS`, w), rule(w)] │
│ .join("\n")} /> │
│ {rows.map(({ r, variant }) => ( │
│ <Pre class={`${variant} toc-row`}>{r.indent}<a class="toc-link" href={`#${r. │
│ slug}`}>{r.title}</a><span class="toc-tail" aria-hidden="true">{` ${r.leader} ${r. │
│ marker}`}</span></Pre> │
│ ))} │
│ </nav> │
│ )} │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ ASTRO ──────────────────────────────┐
│ --- │
│ // Dual-rendered contents block. Rows carry │
│ links, so they render as │
│ // per-row Pres (like Tree) rather than thro │
│ ugh Frame. │
│ import Pre from "../Pre/Pre.astro"; │
│ import Frame from "../Frame/Frame.astro"; │
│ import { rule, row2 } from "../../lib/ascii" │
│ ; │
│ import { FRAME_W, MOBILE_FRAME_W } from "../ │
│ ../lib/config"; │
│ import { layoutToc, type Props, type TocRow │
│ } from "./TableOfContents"; │
│ import "./TableOfContents.scss"; │
│ │
│ const { headings, maxDepth = 3 } = Astro.pro │
│ ps as Props; │
│ const wide = layoutToc(headings, FRAME_W, ma │
│ xDepth); │
│ const narrow = layoutToc(headings, MOBILE_FR │
│ AME_W, maxDepth); │
│ │
│ const row = (r: TocRow, variant: string) => │
│ ({ r, variant }); │
│ const rows = [...wide.map((r) => row(r, "fra │
│ me-wide")), ...narrow.map((r) => row(r, "fra │
│ me-narrow"))]; │
│ --- │
│ {wide.length > 0 && ( │
│ <nav class="toc" aria-label="Contents"> │
│ <Frame build={(w) => [row2("CONTENTS", ` │
│ ${wide.length} SECTIONS`, w), rule(w)].join( │
│ "\n")} /> │
│ {rows.map(({ r, variant }) => ( │
│ <Pre class={`${variant} toc-row`}>{r.i │
│ ndent}<a class="toc-link" href={`#${r.slug}` │
│ }>{r.title}</a><span class="toc-tail" aria-h │
│ idden="true">{` ${r.leader} ${r.marker}`}</s │
│ pan></Pre> │
│ ))} │
│ </nav> │
│ )} │
└──────────────────────────────────────────────┘
──────────────────────────────────────────────────────────────────────────────────────
OOKNET
────────────────────────────────────────────────
OOKNET