Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support relative import inside slides #1744

Merged
merged 22 commits into from
Jul 18, 2024

Conversation

kermanx
Copy link
Member

@kermanx kermanx commented Jul 9, 2024

This PR is based on #1708. It will be much smaller after merging that one.

Previously, it wasn't possible to import assets via relative paths. For example, ![](./assets/a.png). This was because the slides contents were loaded as /@slidev/slide/1.md.

This PR loads the slides in path/to/slides.md as path/to/slides.md__slidev_x.md, where x is the slide no in the presentation, instead of the slide no in that Markdown file. And /@slidev/slide/x.md works as a facade which re-exports path/to/slides.md__slidev_x.md. The same for frontmatter.

The reason why not use urls like path/to/slides.md?slidev=x.md is that this will conflict with Vue's logic. The Vue plugin doesn't preserve the query of the URL. Also, Vue plugin's include option only matches the path part without query string.

This PR also splits vite/loaders.ts into multiple files - each Vite plugin has its own file. And removed most of the usages of enforce/order.

Copy link

netlify bot commented Jul 9, 2024

Deploy Preview for slidev ready!

Name Link
🔨 Latest commit 0eb66ce
🔍 Latest deploy log https://app.netlify.com/sites/slidev/deploys/6698722558519d00084acdec
😎 Deploy Preview https://deploy-preview-1744--slidev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@kermanx kermanx marked this pull request as ready for review July 17, 2024 14:16
@antfu
Copy link
Member

antfu commented Jul 17, 2024

Thanks for working on it! You are amazing!

Copy link
Member

@antfu antfu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am ok with the direction, I'll let you handle the merge and release

@kermanx kermanx merged commit 42d563c into slidevjs:main Jul 18, 2024
18 checks passed
@kermanx kermanx changed the title fix: should support relative import inside slides feat: support relative import inside slides Jul 18, 2024
@kermanx kermanx deleted the fix/allow-relative-path branch July 18, 2024 01:51
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.

2 participants