Replies: 4 comments 5 replies
-
|
+1. However, I'm concerned by one thing: In Vite to get the file path of a file, you can simply import them, right. However, this only works for assets that are part of the So not 100% sure what it'd look like. Maybe it could have a |
Beta Was this translation helpful? Give feedback.
-
|
I don’t know how we could best support file format assertions. The regular Zod approach with One possibility could be that {
/** Vite-provided URL to this asset */
url: string;
/** File extension or MIME type */
format: string;
}Then it’s easier to refine, e.g. asset().refine(({ format }) => ['mov','mp4'].includes(format))That does interfere with whatever the An alternative would probably be an API inside the asset({ formats: ['mov', 'mp4'] }) |
Beta Was this translation helpful? Give feedback.
-
|
I also ran into this issue when embedding videos in markdown. Unlike images, Astro doesn’t process videos — it doesn’t copy them to the build output or update their URLs. Use caseI manage Obsidian-style content where media (images and videos) live next to the markdown in ProposalA generic For videos in markdown body (and any other generic assets), I’m not sure what the best resolution approach would be — open to ideas on how these could be handled. QuestionThis issue has been open for 2 years — was the original proposal accepted in any form, and is there a plan to move it forward? |
Beta Was this translation helpful? Give feedback.
-
|
This would be really great to have it Also, when talking about big files such as videos, it would be even better if there was some kind of internal (optional) way to serve them using some streaming protocol in server-side platforms |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Body
Summary
It would be handy to have an equivalent to the
image()helper for content collection schemas that can resolve arbitrary assets from a relative path in frontmatter.Background & Motivation
Today we’ve made it easy to turn a local image referenced in frontmatter into an image import using our
image()helper for content collections schemas. This works well, but users can’t use the same approach for other assets like videos or PDFs, which is not a smooth DX because you need to switch between techniques depending on the type of asset you’re aiming to load.Goals
importfor.Example
Similar to
image(), use a schema helper to mark a field as needing resolving as an import, something like:Ideally there’d be a way to specify supported file formats?
Content could then set the path:
And a template could use the resolved URL:
Beta Was this translation helpful? Give feedback.
All reactions