Add post-processing/metadata middlewares/plugins on new content collections #1062
spaceemotion
started this conversation in
Proposal
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Body
Summary
For markdown files, we have the global
remarkPlugins
array for any additional steps when reading markdown files.However, any loaders that load other file types (like
.json
or.mdoc
) don't have a way to add plugins during the loading when using theglob
orfile
loaders.Background & Motivation
(Our project already uses the new loaders from the Astro 5.0 beta)
We are working with Markdoc files for our website, as they are more flexible than regular Markdown/MDX. However, certain recipes like the Add last modified time only work with direct file access and as a rehype plugin.
Since we load our Markdoc files via the
glob
loader, they don't go through the Markdown processing pipeline. Figuring out the last modification time via git requires knowing the actual file, which could be done as a callback in the loading step.Technically, we could build our own loader, but that involves a lot of extra steps that seem quite convoluted (like making sure the file watchers work with vite). In case the
generateId
option is used, there's also no way to figure out the original file from a collection entry's ID. Having a way to inject custom meta data in the native file loaders would help.Goals
Example
Beta Was this translation helpful? Give feedback.
All reactions