I want to get the data of the body of my markdown file using the front matter but it is showing undefined, what shall I do to resolve the error?
{latest.map(({ url, frontmatter }) => (
<PostCard url={url} content={frontmatter.body}/>
))}
See the Exported Properties section of the markdown guide in the docs.
frontmatter.body is not part of the list, instead you should use compiledContent() or rawContent() on the imported markdown object.
{latest.map(post => (
<PostCard url={post.url} content={post.compiledContent()} />
))}
When you have src/pages/posts/a.md, src/pages/posts/b.md, etc.
The following shows all files compiled contents successfully:
src/pages/index.astro
---
const posts = await Astro.glob('./posts/*.md')
---
<ul>
{posts.map(post=>
<li set:html={post.compiledContent()} />)}
</ul>