fix: use BASE_URL in getSlidePath for monorepo sub-directory deployments#2562
Open
NgoQuocViet2001 wants to merge 1 commit into
Open
fix: use BASE_URL in getSlidePath for monorepo sub-directory deployments#2562NgoQuocViet2001 wants to merge 1 commit into
NgoQuocViet2001 wants to merge 1 commit into
Conversation
When Slidev is deployed to a sub-directory within a monorepo (e.g., /my_monorepo/my_prez/), the generated slide URLs were hardcoded to start with /export/, /presenter/, or /, ignoring Vite's base option. Now getSlidePath prepends import.meta.env.BASE_URL to the path, matching how other parts of Slidev handle base-relative assets. Fixes: slidevjs#2384
✅ Deploy Preview for slidev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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
When Slidev is deployed to a sub-directory within a monorepo (e.g.,
/my_monorepo/my_prez/), thegetSlidePathfunction inpackages/client/logic/slides.tswas generating URLs that ignored Vite'sbaseoption, resulting in broken navigation to export and presenter pages.Before:
getSlidePath(route, false, false)returned/2regardless of base pathAfter: Returns
${import.meta.env.BASE_URL}2(e.g.,/my_monorepo/my_prez/2)This matches how other parts of Slidev handle base-relative assets (e.g.,
manualChunksinextendConfig.tsusesimport.meta.env.BASE_URL).Changes
packages/client/logic/slides.ts(line 23): Changed hardcoded path prefixes to useimport.meta.env.BASE_URLprepended to the pathtest/utils.test.ts: Added test case that verifies correct path generation with a mockedBASE_URLvalueTest Plan
All 8 tests pass including the new
getSlidePath with base pathtest.Fixes: #2384