docs(site): fix presenter-mode navigation on deployed deck#1163
Open
jamesadevine wants to merge 1 commit into
Open
docs(site): fix presenter-mode navigation on deployed deck#1163jamesadevine wants to merge 1 commit into
jamesadevine wants to merge 1 commit into
Conversation
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>
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.
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:
Root cause
Slidev builds every in-app navigation target with
getSlidePath, which prepends the Vite base:This couples the asset base and the router path to one value, so no single
--baseworks 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:
/— soBASE_URLstays/and hash routes resolve cleanly as/Nand/presenter/Nfor both play and presenter mode.vite.config.ts→experimental.renderBuiltUrl: { relative: true }— emits relative URLs for JS/CSS assets so the bundle loads from the sub-path.postbuild.mjs— rewrites the entry HTML's remaining/assets/…references to./assets/…(the one thingrenderBuiltUrldoesn't cover).routerMode: hash(already onmain) is retained.Test plan
Verified the built deck with a headless browser served at its real
/ado-aw/slides/base:#/1→ advance →#/4— no duplication, correct slide content.#/presenter/1→ advance →#/presenter/4— no duplication, renders.#/6renders, including the Mermaid SVG diagram.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/*.htmlships relative./assets/references.