· 2 min read · updated
Layout, routing and the GitHub Pages base path
Set paths.base from BASE_PATH, which CI sets to /${{ github.event.repository.name }}. The value is validated in vite.config.ts, and the build throws if it's…
What we did
- Set
paths.basefromBASE_PATH, which CI sets to/${{ github.event.repository.name }}. The value is validated invite.config.ts, and the build throws if it's malformed. - Created stub routes:
/cv,/projects,/awesome,/blog,/bitacora. Moved the/devcontent into/bitacora. - Built
Header,NavandFooterinsrc/lib/components/and wrapped pages in<main>. - The nav is built from a typed array (
href: RouteId) with a keyed{#each}, and the active link getsaria-current="page".
What I learned
processneeds@types/node.tsconfigincludetakes file paths, not package names.aschecks nothing. Validate runtime values (env vars) first, then cast. A cast right after a check is honest.- Types protect values written in code. Runtime checks protect values that arrive from outside, like env vars, input and frontmatter.
resolve()only accepts real routes. TypinghrefasRouteIdturned typos and missing routes into type errors.href="resolve('/')"is a string.href={resolve('/')}is code, and svelte-check can't tell the difference.- On GitHub Pages
page.url.pathnameincludes the base, so compare againstresolve(href). - Svelte drops attributes whose value is
undefined, which keepsaria-current={active ? 'page' : undefined}clean. - Prerendered links are relative (
./blog), so/portfoliodoesn't appear in the HTML. VAR=x a && bsetsVARonly fora. To preview like GitHub Pages:BASE_PATH=/portfolio pnpm build && BASE_PATH=/portfolio pnpm preview.- One
<h1>per page. The site name in the header is not a heading.
Problems & fixes
pnpm lintfailed on the workflow because of double quotes. Read which file the tool names before blaming the environment (Node 24 vs 22 wasn't the cause).- Nav hrefs were
'home'and'about'(missing/, and routes that don't exist). TheRouteIdtype caught them.
Next
- Phase 3: design system with Open Props.