feat(router,website): base-path support for subpath deployments - #114
Draft
stefvw93 wants to merge 5 commits into
Draft
feat(router,website): base-path support for subpath deployments#114stefvw93 wants to merge 5 commits into
stefvw93 wants to merge 5 commits into
Conversation
The Pages project site serves at stefvw93.github.io/weft/, but the static build emitted root-absolute asset and link URLs, so JS/CSS 404'd and every internal link escaped the subpath. Router (@weftui/router): new `base` option on RouterLive and RouterServer.render. URLs inside the router stay canonical (base-less) — the base is stripped/prefixed only at the boundaries: location reads, History writes, the link click interceptor, and the server render URL. Hrefs outside the base fall through to the browser. Website: SITE_BASE env drives Vite `base` in both configs; src/lib/site-base.ts exposes the normalized base and withBase(), applied to every app-rendered internal href (nav, prev/next, home, 404, markdown links via render-hast). Prerender renders base-prefixed URLs into base-less output files (the artifact root is the base). The build tasks declare `env: ["SITE_BASE"]` — vp tasks run in a clean environment, so this both passes the variable through and fingerprints the cache. CI: the Pages deploy build sets SITE_BASE=/weft/. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
# Conflicts: # graphify-out/.graphify_labels.json # graphify-out/GRAPH_REPORT.md # graphify-out/graph.html # graphify-out/graph.json # graphify-out/manifest.json # packages/router/src/client/router-live.test.ts # website/src/entry-client.ts # website/src/layouts/docs-shell.ts
stefvw93
marked this pull request as draft
July 4, 2026 19:53
# Conflicts: # graphify-out/.graphify_labels.json # graphify-out/GRAPH_REPORT.md # graphify-out/graph.html # graphify-out/graph.json # graphify-out/manifest.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The GitHub Pages deploy works, but the site is broken at
stefvw93.github.io/weft/: every asset and internal link is root-absolute (/assets/…,/docs/…), so JS/CSS fetch fromstefvw93.github.io/assets/…→ 404, and hard links escape the subpath.Approach
Route patterns keep their literal strings (segment-string type inference stays intact); the base is handled at the URL boundaries instead.
@weftui/router— newbaseoption (spec:packages/router/src/base.specs.md):RouterLive({ base }): strips the base on location reads (seed, popstate), prefixes it on History writes, and the link interceptor matches/navigates on the stripped href — same-origin hrefs outside the base fall through to the browser.RouterServer.render({ url, base }): strips before matching; URLs outside the base render the 404 page.match.url,navigatetargets, and everything stored in the router stay base-less. No behavior change whenbaseis omitted.Website (spec:
website/prerender.specs.md, "Subpath deployment"):SITE_BASEenv → Vitebasein both configs;src/lib/site-base.tsexposes the normalizedSITE_BASE+withBase().withBase(docs-shell nav/prev-next/home, landing page, 404 page, markdown links viarender-hast).SITE_BASE + pathbut writes base-less output files — the artifact root is the base.env: ["SITE_BASE"]: vp tasks run in a clean environment, so this is required both to pass the variable through and to fingerprint the task cache (a base change was silently reusing stale root-base bundles — including the CI-restored task cache).CI: the
Deploy Websitebuild step setsSITE_BASE=/weft/.Validation
vp run checkclean;vp run test597/597 (new: router base helpers + RouterLive/interceptor/server-render base cases, site-base tests);vp run test:browser36/36.SITE_BASE=/weft/ vp run build:static, served under a/weft/prefix — all pages 200, entry JS + CSS 200 at/weft/assets/…, zero stray non-base hrefs,404.htmlcorrect.SITE_BASEis root-absolute as before (cache correctly invalidates both directions).After merge: release → deploy runs with the base baked in; site at
stefvw93.github.io/weft/becomes fully functional. If a custom domain is added later, deleting theSITE_BASEenv line reverts to root serving.🤖 Generated with Claude Code