#Rendering collection entry outside of .astro template

5 messages · Page 1 of 1 (latest)

wispy kiln
#

In Astro v1.x, I could use the compiledContent() method to render a post into a string programmatically. Is there an equivalent in Astro v2.0? It seems like CollectionEntry#render() only returns a component to drop into a .astro page? When I call Content() directly, I get an error because I'm not passing in the right arguments, but I can't find any reference explaining what those arguments should be or if this is even possible.

For reference, here's what I'm doing with Astro v1.x:
https://github.com/humanwhocodes/humanwhocodes.com/blob/f44b87a5ba38faa8b5b68969f6bb279a8d07ac34/src/pages/feeds/blog.json.js#L30

GitHub

Contribute to humanwhocodes/humanwhocodes.com development by creating an account on GitHub.

runic kraken
#

compiledContent() has never been available for MDX so we held off adding an equivalent to content collections until we can offer a consistent API across content types. The team is working on an API that would unlock this hopefully.

In the meantime here’s the pattern suggested in the docs: https://docs.astro.build/en/guides/rss/#including-full-post-content

Astro Documentation
RSS

An intro to RSS in Astro

#

(Docs suggest markdown-it but you could also use remark if you wanted consistency with your Markdown rendering config elsewhere.)

wispy kiln
#

Thank you!