Skip to content

Commit 751aeb5

Browse files
committed
fix(serve): route /<slug>/ and /<slug> to index.html
Local serve was returning 404 on /socket-packageurl-js/ — the slug- prefixed root that GH Pages serves the site at and the home link (<a href='/'>) falls back to when base-path rewrite runs. Only the bare /, /<slug>/part/<n>, and /<slug>/documents shapes were handled. Add an explicit match for /<slug> and /<slug>/ → index.html so the dev server matches production URL shape.
1 parent 0d7f2e8 commit 751aeb5

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

scripts/walkthrough.mts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,12 +810,18 @@ function readSlug(): string {
810810

811811
function routeToFile(slug: string, urlPath: string): string | undefined {
812812
// / → index.html
813+
// /<slug> or /<slug>/ → index.html (slug-prefixed root, same as the
814+
// URL GH Pages serves the site at; matches
815+
// the flat file name emitted by meander)
813816
// /<slug>/part/<n> → walkthrough-part-<n>.html
814817
// /<slug>/documents → documents.html
815818
// anything else → as-is (e.g. /walkthrough.css)
816819
if (urlPath === '/' || urlPath === '') {
817820
return 'index.html'
818821
}
822+
if (urlPath === `/${slug}` || urlPath === `/${slug}/`) {
823+
return 'index.html'
824+
}
819825
const partMatch = new RegExp(`^/${slug}/part/(\\d+)/?$`).exec(urlPath)
820826
if (partMatch) {
821827
return `walkthrough-part-${partMatch[1]}.html`

0 commit comments

Comments
 (0)