#`render()` function of a content collection entry
3 messages · Page 1 of 1 (latest)
Hi @formal breach. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
The render() function of a content collection entry in Astro does not directly provide the HTML string. Instead, it returns a <Content /> component and other properties like headings and remarkPluginFrontmatter. The <Content /> component is used to render the document’s contents in an Astro file.
---import { getEntryBySlug } from 'astro:content';
const entry = await getEntryBySlug('blog', 'entry-1');
const { Content, headings, remarkPluginFrontmatter } = await entry.render();---
(Source: Astro API Reference (https://docs.astro.build/en/reference/api-reference/#render))
However, if you want to manipulate the HTML string before processing it into a <Fragment set:html>, you might need to convert the <Content /> component to a string. Unfortunately, the provided knowledge sources do not provide information on how to convert an Astro component to a string.