Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ export class PreviewServer {
try {
if ((await stat(path)).isDirectory() && (await stat(join(path, "index") + ".md")).isFile()) {
await access(join(path, "index") + ".md", constants.R_OK);
if (!pathname.endsWith("/")) {
res.writeHead(302, {Location: pathname + "/" + url.search});
res.end();
return;
}
pathname = join(pathname, "index");
path = join(path, "index");
}
Expand Down
4 changes: 3 additions & 1 deletion test/input/build/multi/subsection/index.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Sub-Section

This is a sub-section of the multi-section page.
This is a sub-section of the multi-section page.

We can link to [this sub-section](./) and to [the parent section](../).
1 change: 1 addition & 0 deletions test/output/build/multi/subsection/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<main id="observablehq-main" class="observablehq">
<h1 id="sub-section" tabindex="-1"><a class="observablehq-header-anchor" href="#sub-section">Sub-Section</a></h1>
<p>This is a sub-section of the multi-section page.</p>
<p>We can link to <a href="./">this sub-section</a> and to <a href="../">the parent section</a>.</p>
</main>
<footer id="observablehq-footer">
<nav><a rel="prev" href="../"><span>Home</span></a></nav>
Expand Down