Skip to content

Commit

Permalink
skip index.md in default sidebar (#404)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock authored Dec 19, 2023
1 parent 550daaf commit 56cce2a
Show file tree
Hide file tree
Showing 8 changed files with 1 addition and 48 deletions.
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export async function readDefaultConfig(root?: string): Promise<Config> {
async function readPages(root: string): Promise<Page[]> {
const pages: Page[] = [];
for await (const file of visitFiles(root)) {
if (file === "404.md" || extname(file) !== ".md") continue;
if (file === "index.md" || file === "404.md" || extname(file) !== ".md") continue;
const parsed = await parseMarkdown(await readFile(join(root, file), "utf-8"), root, file);
const name = basename(file, ".md");
const page = {path: join("/", dirname(file), name), name: parsed.title ?? "Untitled"};
Expand Down
1 change: 0 additions & 1 deletion test/config-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ describe("normalizeConfig(spec, root)", () => {
});
it("populates default pages", async () => {
assert.deepStrictEqual((await config({}, root)).pages, [
{name: "Index", path: "/index"},
{name: "One", path: "/one"},
{name: "H1: Section", path: "/toc-override"},
{name: "H1: Section", path: "/toc"},
Expand Down
11 changes: 0 additions & 11 deletions test/output/build/missing-file/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,6 @@
}});

</script>
<input id="observablehq-sidebar-toggle" type="checkbox" title="Toggle sidebar">
<label id="observablehq-sidebar-backdrop" for="observablehq-sidebar-toggle"></label>
<nav id="observablehq-sidebar">
<ol>
<li class="observablehq-link observablehq-link-active"><a href="./">Home</a></li>
</ol>
<ol>
<li class="observablehq-link observablehq-link-active"><a href="./">Build test case</a></li>
</ol>
</nav>
<script>{/* redacted init script */}</script>
<aside id="observablehq-toc" data-selector="#observablehq-main h1:not(:first-of-type), #observablehq-main h2:not(h1 + h2)">
<nav>
</nav>
Expand Down
11 changes: 0 additions & 11 deletions test/output/build/missing-import/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,6 @@
}});

</script>
<input id="observablehq-sidebar-toggle" type="checkbox" title="Toggle sidebar">
<label id="observablehq-sidebar-backdrop" for="observablehq-sidebar-toggle"></label>
<nav id="observablehq-sidebar">
<ol>
<li class="observablehq-link observablehq-link-active"><a href="./">Home</a></li>
</ol>
<ol>
<li class="observablehq-link observablehq-link-active"><a href="./">Build test case</a></li>
</ol>
</nav>
<script>{/* redacted init script */}</script>
<aside id="observablehq-toc" data-selector="#observablehq-main h1:not(:first-of-type), #observablehq-main h2:not(h1 + h2)">
<nav>
</nav>
Expand Down
1 change: 0 additions & 1 deletion test/output/build/multi/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
</ol>
<ol>
<li class="observablehq-link"><a href="./subsection/">Sub-Section</a></li>
<li class="observablehq-link observablehq-link-active"><a href="./">Multi test</a></li>
</ol>
</nav>
<script>{/* redacted init script */}</script>
Expand Down
1 change: 0 additions & 1 deletion test/output/build/multi/subsection/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
</ol>
<ol>
<li class="observablehq-link observablehq-link-active"><a href="./">Sub-Section</a></li>
<li class="observablehq-link"><a href="../">Multi test</a></li>
</ol>
</nav>
<script>{/* redacted init script */}</script>
Expand Down
11 changes: 0 additions & 11 deletions test/output/build/simple-public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,6 @@
import "./_observablehq/client.js";

</script>
<input id="observablehq-sidebar-toggle" type="checkbox" title="Toggle sidebar">
<label id="observablehq-sidebar-backdrop" for="observablehq-sidebar-toggle"></label>
<nav id="observablehq-sidebar">
<ol>
<li class="observablehq-link observablehq-link-active"><a href="./">Home</a></li>
</ol>
<ol>
<li class="observablehq-link observablehq-link-active"><a href="./">Build test case</a></li>
</ol>
</nav>
<script>{/* redacted init script */}</script>
<aside id="observablehq-toc" data-selector="#observablehq-main h1:not(:first-of-type), #observablehq-main h2:not(h1 + h2)">
<nav>
</nav>
Expand Down
11 changes: 0 additions & 11 deletions test/output/build/subtitle/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,6 @@
import "./_observablehq/client.js";

</script>
<input id="observablehq-sidebar-toggle" type="checkbox" title="Toggle sidebar">
<label id="observablehq-sidebar-backdrop" for="observablehq-sidebar-toggle"></label>
<nav id="observablehq-sidebar">
<ol>
<li class="observablehq-link observablehq-link-active"><a href="./">Home</a></li>
</ol>
<ol>
<li class="observablehq-link observablehq-link-active"><a href="./">A title</a></li>
</ol>
</nav>
<script>{/* redacted init script */}</script>
<aside id="observablehq-toc" data-selector="#observablehq-main h1:not(:first-of-type), #observablehq-main h2:not(h1 + h2)">
<nav>
<div>Contents</div>
Expand Down

0 comments on commit 56cce2a

Please sign in to comment.