-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Change frontmatter injection ordering #5687
Conversation
🦋 Changeset detectedLatest commit: 3d50fa8 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@@ -36,33 +35,6 @@ export function getFileInfo(id: string, config: AstroConfig) { | |||
return { fileId, fileUrl }; | |||
} | |||
|
|||
function isValidAstroData(obj: unknown): obj is MarkdownAstroData { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move frontmatter injection utils to @astrojs/markdown-remark
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blocking as we are not ready to merge major
changes into main just yet.
Code looks good! Let's talk about this with the core team before merging next week. |
f82f700
to
c85688c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was interesting to see how you readjusted the order of the frontmatter process.
So its now safe to say that frontmatter is mutable via the remark tree and the output of that is what is then provided into other contexts
@@ -520,6 +520,20 @@ See https://docs.astro.build/en/guides/server-side-rendering/ for more informati | |||
}, | |||
hint: 'See https://docs.astro.build/en/guides/content-collections/ for more information on content schemas.', | |||
}, | |||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💚 this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved by TSC, @bholmesdev just need to fix the conflicts.
38a1133
to
3d50fa8
Compare
export { Content, getHeadings, _internal } from ${JSON.stringify(basePath)}; | ||
export { Content, getHeadings } from ${JSON.stringify(basePath)}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems frontmatter
needed to be added here where _internal
was removed.
Changes
Give remark and rehype plugins access to user frontmatter via frontmatter injection. This means
data.astro.frontmatter
is now the complete Markdown or MDX document's frontmatter, rather than an empty object.This allows plugin authors to modify existing frontmatter, or compute new properties based on other properties. For example, say you want to compute a full image URL based on an
imageSrc
slug in your document frontmatter:Content Collections change
We have changed inject frontmatter to modify frontmatter in our docs to improve discoverability. This is based on support forum feedback where injection is rarely the term used.
To reflect this, the
injectedFrontmatter
property has been renamed toremarkPluginFrontmatter
. This should clarify this plugin is still separate from thedata
export Content Collections expose today. We also expectremarkPluginFrontmatter
to be deprecated once schemas can compute frontmatter based on file contents.Testing
Docs
withastro/docs#2250