PageToc
uses process
The sections of the page kept in file, for the menu, rendered on the server from the page.
import { renderedDoc } from "#codebase/tcmts/site"; import type { TocEntry } from "#codebase/tcmts/site"; export async function PageToc({ file }: { file: string }) { // (the page as `DocsPage` renders it: once for both) const { toc }: { toc: TocEntry[] } = ( await renderedDoc(file, process.env.TCM_SITE_VERSION !== undefined) ).rendered; if (!toc.length) return null; return ( <ul> {toc.map((t) => ( <li key={t.id}> <a href={`#${t.id}`}> {t.num} {t.text.toLowerCase()} </a> </li> ))} </ul> ); }