#How do I render the Markdown on the entry returned from `getEntry()`?

3 messages · Page 1 of 1 (latest)

azure forge
#

In this case:

---
const article = await getEntry("example", "article");
---
{article.render()}

How do I get the actual article contents, which in my case is a markdown file, to render the output of the file onto the page? The above code just outputs [object Object]

azure forge
#

How do I render the Markdown on the entry returned from getEntry()?

thin lava
#

article.render returns an object containing the Content component and some other items. You can destruct this like so

---
const article = ...
const { Content } = article.render()
---
<Content/>

See: Rendering content to HTML

Astro Documentation

Content collections help organize your Markdown and type-check your frontmatter with schemas.