You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently there is no way to render a string programmatically with markdown/markdoc integration. For precise control over our content this would be great improvement.
Why?
In my use case I try to render OpenApi documents with astro. So each path inside the document contains description. The description field could be markdown/markdoc. I spent my whole week for how to integrate the process with the current markdoc integration but I couldn't find a way. In Nuxt there is a ContentRenderer component and when you pass there the markdown string it renders correctly by using your existing config (Custom components, plugins etc.)
I tried using loader api with v5 but I couldn't make it work unless I extract the description fields as custom files and honestly even if it would have worked it seems totally development overhead for a such simple use case.
Astro already have a render function exposed from astro:content but it doesn't work without using getEntry.
My proposal is actually for the content layer being as dynamic as possible for covering all use cases. Currently it is completely file based.
Example
---import { MarkdocRenderer } from"astro:content";const data =`# example markdoc`---
<MarkdocRenderercontent={data} />
Or as a function
---import { renderString } from"astro:content";const data =`# example markdoc`const Content =awaitrenderString(data, { type: "markdoc" })---
<Content />
This would remove lots of headaches and provide more control to the end user.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Body
Summary
Currently there is no way to render a string programmatically with markdown/markdoc integration. For precise control over our content this would be great improvement.
Why?
In my use case I try to render OpenApi documents with astro. So each path inside the document contains description. The
description
field could be markdown/markdoc. I spent my whole week for how to integrate the process with the current markdoc integration but I couldn't find a way. In Nuxt there is aContentRenderer
component and when you pass there the markdown string it renders correctly by using your existing config (Custom components, plugins etc.)I tried using loader api with
v5
but I couldn't make it work unless I extract thedescription
fields as custom files and honestly even if it would have worked it seems totally development overhead for a such simple use case.Astro already have a render function exposed from
astro:content
but it doesn't work without usinggetEntry
.My proposal is actually for the content layer being as dynamic as possible for covering all use cases. Currently it is completely file based.
Example
Or as a function
This would remove lots of headaches and provide more control to the end user.
Beta Was this translation helpful? Give feedback.
All reactions