Skip to content

fix(docs-site): patch elm-pages base path for GitHub Pages#30

Merged
ryanbas21 merged 1 commit into
mainfrom
feat/docs-site
May 12, 2026
Merged

fix(docs-site): patch elm-pages base path for GitHub Pages#30
ryanbas21 merged 1 commit into
mainfrom
feat/docs-site

Conversation

@ryanbas21
Copy link
Copy Markdown
Owner

Summary

  • Patch elm-pages v3.5.1 codegen to fix urlToRoute not stripping the base path (causing all pages to pre-render as "Page not found")
  • Simplify CI workflow — patched build outputs correct structure directly
  • Fixes the broken deployment at ryanbas21.github.io/devtools/

This is a follow-up to #29 which configured the base path but hit an elm-pages bug where the pre-renderer couldn't match routes.

What was wrong

elm-pages' --base /devtools/ flag correctly sets baseUrl for link generation, but the generated urlToRoute function passes the full URL path (e.g., /devtools/docs/getting-started) directly to segmentsToRoute without stripping the base prefix first. Every route match fails, so all pages pre-render as "Page not found."

The fix

A pnpm patch on elm-pages@3.5.1 that inlines base-path stripping into the urlToRoute codegen, so the generated function becomes:

urlToRoute url =
    if String.startsWith baseUrl url.path then
        segmentsToRoute (splitPath (String.dropLeft (String.length baseUrl) url.path))
    else
        segmentsToRoute (splitPath url.path)

Test plan

  • CI build passes
  • Visit ryanbas21.github.io/devtools/ — should show full landing page with styling
  • Navigation links resolve correctly (sidebar, header, package cards)
  • Client-side SPA routing works (clicking links doesn't full-page reload)
  • Direct URL access works (e.g., /devtools/docs/getting-started)

🤖 Generated with Claude Code

The elm-pages v3.5.1 --base flag has a bug: the generated urlToRoute
function doesn't strip the base path before matching routes, causing all
pages to pre-render as "Page not found." This patch fixes the codegen
to inline the base path stripping logic into urlToRoute.

Also simplifies the CI workflow — the patched build outputs files at the
dist root with correct /devtools/ prefixed links, so we just upload dist/
directly instead of restructuring the output.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ryanbas21 ryanbas21 merged commit 121e549 into main May 12, 2026
1 check passed
@ryanbas21 ryanbas21 deleted the feat/docs-site branch May 12, 2026 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant