Skip to content

docs(site): fix presenter-mode navigation on deployed deck#1163

Open
jamesadevine wants to merge 1 commit into
mainfrom
devinejames/slides-presenter-fix
Open

docs(site): fix presenter-mode navigation on deployed deck#1163
jamesadevine wants to merge 1 commit into
mainfrom
devinejames/slides-presenter-fix

Conversation

@jamesadevine

Copy link
Copy Markdown
Collaborator

Summary

Fixes presenter-mode navigation on the deployed intro deck. After the earlier routing fix (#1153), play mode worked but advancing slides in presenter mode duplicated the path segment:

…/ado-aw/slides/#/presenter/presenter/2

Root cause

Slidev builds every in-app navigation target with getSlidePath, which prepends the Vite base:

const path = presenter ? `presenter/${no}` : `${no}`
return `${import.meta.env.BASE_URL}${path}`

This couples the asset base and the router path to one value, so no single --base works for a sub-path deploy:

  • --base /ado-aw/slides/ → base leaks into the route (#/ado-aw/slides/2) — breaks both modes.
  • --base ./ → play works (#/2), but presenter pushes ./presenter/2, which Vue Router resolves relative to /presenter/1/presenter/presenter/2 — breaks presenter.

Fix

Decouple the two:

  1. Build with the default base / — so BASE_URL stays / and hash routes resolve cleanly as /N and /presenter/N for both play and presenter mode.
  2. vite.config.tsexperimental.renderBuiltUrl: { relative: true } — emits relative URLs for JS/CSS assets so the bundle loads from the sub-path.
  3. postbuild.mjs — rewrites the entry HTML's remaining /assets/… references to ./assets/… (the one thing renderBuiltUrl doesn't cover).

routerMode: hash (already on main) is retained.

Test plan

Verified the built deck with a headless browser served at its real /ado-aw/slides/ base:

  • Play: #/1 → advance → #/4 — no duplication, correct slide content.
  • Presenter: #/presenter/1 → advance → #/presenter/4no duplication, renders.
  • Deep-link reload at #/6 renders, including the Mermaid SVG diagram.
  • Zero page errors.
  • cd site && npm run build (the CI path: npm --prefix slides ci --omit=dev + slidev build + postbuild + astro build) completes; links validation passes; dist/slides/*.html ships relative ./assets/ references.

Presenter mode on the published deck duplicated the path segment when advancing slides (…/#/presenter/presenter/2). Slidev's getSlidePath() prepends the Vite base (import.meta.env.BASE_URL) to every router target, so any non-root base leaks into — or, for nested presenter routes, compounds in — the hash route.

Build the deck with the default base / (so BASE_URL stays / and hash routes resolve cleanly as /N and /presenter/N for both play and presenter), emit relative asset URLs via Vite experimental.renderBuiltUrl, and post-build rewrite the entry HTML's /assets/ references to ./assets/ so the bundle still loads from /ado-aw/slides/.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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