diff --git a/src/render.ts b/src/render.ts index 28176ad1a..a5ef16e71 100644 --- a/src/render.ts +++ b/src/render.ts @@ -54,7 +54,6 @@ type RenderInternalOptions = async function render(parseResult: ParseResult, options: RenderOptions & RenderInternalOptions): Promise { const {root, path, pages, title, preview} = options; const toc = mergeToc(parseResult.data?.toc, options.toc); - const headers = toc.show ? findHeaders(parseResult) : []; return String(html` ${path === "/404" ? html`\n` : ""} @@ -85,7 +84,7 @@ ${ preview ? `\nopen({hash: ${JSON.stringify(parseResult.hash)}, eval: (body) => (0, eval)(body)});\n` : "" }${parseResult.cells.map((cell) => `\n${renderDefineCell(cell)}`).join("")}`)} ${pages.length > 0 ? html`\n${await renderSidebar(title, pages, path)}` : ""}${ - headers.length > 0 ? html`\n${renderToc(headers, toc.label)}` : "" + toc.show ? html`\n${renderToc(findHeaders(parseResult), toc.label)}` : "" }
@@ -139,16 +138,20 @@ function findHeaders(parseResult: ParseResult): Header[] { .filter((d): d is Header => !!d.label && !!d.href); } -function renderToc(headers: Header[], label = "Contents"): Html { +function renderToc(headers: Header[], label: string): Html { return html``; } diff --git a/test/output/build/404/404.html b/test/output/build/404/404.html index 3412799ac..9df130d72 100644 --- a/test/output/build/404/404.html +++ b/test/output/build/404/404.html @@ -24,6 +24,10 @@ import "./_observablehq/client.js"; +

Page not found

diff --git a/test/output/build/archives/tar.html b/test/output/build/archives/tar.html index 35d9019a8..c18db6fad 100644 --- a/test/output/build/archives/tar.html +++ b/test/output/build/archives/tar.html @@ -69,6 +69,10 @@ +

Tar

diff --git a/test/output/build/archives/zip.html b/test/output/build/archives/zip.html index e2e9354e6..2938d197b 100644 --- a/test/output/build/archives/zip.html +++ b/test/output/build/archives/zip.html @@ -55,6 +55,10 @@ +

Zip

diff --git a/test/output/build/config/closed/page.html b/test/output/build/config/closed/page.html index 83affa110..f738e1395 100644 --- a/test/output/build/config/closed/page.html +++ b/test/output/build/config/closed/page.html @@ -34,6 +34,10 @@ +

A page…

diff --git a/test/output/build/config/index.html b/test/output/build/config/index.html index 1b550e67d..25e4f5d73 100644 --- a/test/output/build/config/index.html +++ b/test/output/build/config/index.html @@ -34,6 +34,10 @@ +

Index

diff --git a/test/output/build/config/one.html b/test/output/build/config/one.html index de18ff70b..407c06f1a 100644 --- a/test/output/build/config/one.html +++ b/test/output/build/config/one.html @@ -34,6 +34,10 @@ +

One

diff --git a/test/output/build/config/sub/two.html b/test/output/build/config/sub/two.html index 4eb744e2a..c9e7d0b3b 100644 --- a/test/output/build/config/sub/two.html +++ b/test/output/build/config/sub/two.html @@ -34,6 +34,10 @@ +

Two

diff --git a/test/output/build/fetches/foo.html b/test/output/build/fetches/foo.html index 8a423dba0..ce86c3365 100644 --- a/test/output/build/fetches/foo.html +++ b/test/output/build/fetches/foo.html @@ -36,6 +36,10 @@ +

Top

diff --git a/test/output/build/fetches/top.html b/test/output/build/fetches/top.html index 363283279..843ccd644 100644 --- a/test/output/build/fetches/top.html +++ b/test/output/build/fetches/top.html @@ -39,6 +39,10 @@ +

Top

diff --git a/test/output/build/files/files.html b/test/output/build/files/files.html index 9875663a7..6803340fc 100644 --- a/test/output/build/files/files.html +++ b/test/output/build/files/files.html @@ -50,6 +50,10 @@ +
diff --git a/test/output/build/files/subsection/subfiles.html b/test/output/build/files/subsection/subfiles.html index 73640a726..e810c3fe0 100644 --- a/test/output/build/files/subsection/subfiles.html +++ b/test/output/build/files/subsection/subfiles.html @@ -50,6 +50,10 @@ +
diff --git a/test/output/build/imports/foo/foo.html b/test/output/build/imports/foo/foo.html index c54c5eae4..ee9687990 100644 --- a/test/output/build/imports/foo/foo.html +++ b/test/output/build/imports/foo/foo.html @@ -42,6 +42,10 @@ +

Foo

diff --git a/test/output/build/missing-file/index.html b/test/output/build/missing-file/index.html index 5c3d78abd..46ecb3e57 100644 --- a/test/output/build/missing-file/index.html +++ b/test/output/build/missing-file/index.html @@ -32,6 +32,10 @@ +

Build test case

diff --git a/test/output/build/missing-import/index.html b/test/output/build/missing-import/index.html index 63b2de271..f90628a0a 100644 --- a/test/output/build/missing-import/index.html +++ b/test/output/build/missing-import/index.html @@ -33,6 +33,10 @@ +

Build test case

diff --git a/test/output/build/multi/index.html b/test/output/build/multi/index.html index 23b37c39e..3e6e1d21e 100644 --- a/test/output/build/multi/index.html +++ b/test/output/build/multi/index.html @@ -43,6 +43,10 @@ +

Multi test

diff --git a/test/output/build/multi/subsection/index.html b/test/output/build/multi/subsection/index.html index 966b90de1..8b6bf4bc0 100644 --- a/test/output/build/multi/subsection/index.html +++ b/test/output/build/multi/subsection/index.html @@ -27,6 +27,10 @@ +

Sub-Section

diff --git a/test/output/build/simple-public/index.html b/test/output/build/simple-public/index.html index 0b2886236..5cdb996e9 100644 --- a/test/output/build/simple-public/index.html +++ b/test/output/build/simple-public/index.html @@ -26,6 +26,10 @@ +

Build test case

diff --git a/test/output/build/simple/simple.html b/test/output/build/simple/simple.html index 5c4ff0b56..64bf1149f 100644 --- a/test/output/build/simple/simple.html +++ b/test/output/build/simple/simple.html @@ -35,6 +35,10 @@ +