How to render remote markdown using content layer API #9543
Labels
5.0
For 5.0 stable release
add new content
Document something that is not in docs. May require testing, confirmation, or affect other pages.
📚 Subject area/topic
markdown, content layer api
📋 Suggested page
https://docs.astro.build/en/reference/configuration-reference/#experimentalcontentlayer
📋 General description or bullet points (if proposing new content)
I think that with the new content layer API, rendering remote markdown (from a server or api) is going to be a common use case.
The Astro docs currently says "Astro does not include built-in support for remote Markdown outside of experimental content collections!"
However I was unable to find any further information or examples about rendering remote (server) markdown.
So firstly, I was wondering if there already is an good example that I have missed?
If not, I have got some rough code (shown below) that renders markdown using Astros built in functions that seems to work and might help someone. But I would really like someone to review it and let me know things that can be improved.
Example Loader that renders remote markdown:
The markdown HTML can be displayed on the page using the "render" function and built in "Content" component:
As I said, I'm sure there are things above that could be done better.
🖥️ Reproduction of code samples in StackBlitz
No response
The text was updated successfully, but these errors were encountered: