withastro / astro

The web framework for content-driven websites. ⭐️ Star to support our work!
https://astro.build
Other
46.82k stars 2.49k forks source link

remarkPluginFrontmatter is undefined after render #5859

Closed fflaten closed 1 year ago

fflaten commented 1 year ago

What version of astro are you using?

2.0.0-beta.2

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

npm

What operating system are you using?

Linux

Describe the Bug

When using content collections with Astro v2 beta, I'm unable to access frontmatter by a remark plugin.

const { remarkPluginFrontmatter } = await post.render();
/* remarkPluginFrontmatter is undefined */

With Astro v.1.9 this works fine when using injectedFrontmatter. See blog.astro page in repro.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-a5wsjy

Participation

bluwy commented 1 year ago

Looks like this was changed at https://github.com/withastro/astro/pull/5687

https://github.com/withastro/astro/blob/c2a3293f7f7ad561f177cf31c8c4862c56b9530f/packages/astro/src/content/internal.ts#L143

But I can't seem to find where mod.frontmatter would originate from

izmttk commented 1 year ago

@bluwy It seems to be because that the frontmatter property is not exported in the loader of vite-plugin-content-assets.

https://github.com/withastro/astro/blob/02ba7c2250a950593961d833201e46adb3e0873c/packages/astro/src/content/vite-plugin-content-assets.ts#L37