fix: correct default sectionImage path in new-section layout#12
Open
dp-daesung wants to merge 1 commit intoDawntraoz:masterfrom
Open
fix: correct default sectionImage path in new-section layout#12dp-daesung wants to merge 1 commit intoDawntraoz:masterfrom
dp-daesung wants to merge 1 commit intoDawntraoz:masterfrom
Conversation
The previous default '../public/section-illustration.svg' is a relative path that does not start with '/', so resolveAssetUrl passes it through unchanged. Browsers then try to resolve it relative to the page URL, causing the illustration to fail to load. Changing the default to '/section-illustration.svg' makes resolveAssetUrl prepend BASE_URL correctly, matching how Slidev serves theme public assets at the root path. Fixes Dawntraoz#8
44cd1bd to
6d1fbd4
Compare
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 default value for
sectionImageinlayouts/new-section.vueis../public/section-illustration.svg. Since this path does not start with/,resolveAssetUrlpasses it through unchanged. The browser then tries to resolve it relative to the page URL, which fails — leaving the section slide with no illustration.Reported in #8.
Root Cause: Regression in 1.1.2
In 1.1.1, the layout imported
resolveAssetUrlfrom@slidev/client/layoutHelper, which handled the relative path correctly. PR #6 replaced this with a local../layoutHelper, whose implementation only processes paths starting with/:The default value
../public/section-illustration.svgwas never updated to match, causing it to break in 1.1.2.How Slidev Serves Theme Public Assets
Slidev uses
vite-plugin-static-copyto serve themepublic/assets under the/theme/path (not/). Sosection-illustration.svgfrom the theme package is available at/theme/section-illustration.svg.Fix
Change the default from
../public/section-illustration.svgto/theme/section-illustration.svg:This allows
sectionImageto be safely omitted in frontmatter and the illustration will render correctly.Fixes #8