slidev icon indicating copy to clipboard operation
slidev copied to clipboard

baseURL for assets referred in frontmatter

Open kermanx opened this issue 10 months ago • 2 comments

Assets paths in frontmatter won't be resolved by Vite, thus they will be broken once baseURL changes.

However, there is no way to automatically detect whether a string in the frontmatter is a path or not.

We may need a placeholder for base URLs. For example:

---
background: ${BASE_URL}/image.png
# Or ${BASE_URL}image.png because BASE_URL by Vite's definition starts and ends with a slash
---

Ref https://github.com/slidevjs/slidev/issues/2005#issuecomment-2638158519

kermanx avatar Feb 06 '25 15:02 kermanx

so, it's possible that ${BASE_URL} would work, but the FAQs on asset handling seems to point to frontmatter will resolve correctly post-build? https://sli.dev/guide/faq#assets-handling

maybe i'm misunderstanding, but i also know that a wrench i threw into the mix as a non-standard kind of asset (.bib and .csl – which are almost exclusively academically used assets).

jmuchovej avatar Feb 08 '25 19:02 jmuchovej

I found that it worked for favicon: /favicon.png, but not for background, which needed background: ./cover.jpg.

lishaduck avatar Feb 19 '25 19:02 lishaduck