#what is the best way to render external markdown in astro?
28 messages · Page 1 of 1 (latest)
supposed to be
Wordpress itself does not make Markdown available, but HTML instead... you could use the HTML output directly to save a step.
data.content.rendered is the HTML output on the page/post data tree
If you are looking for a way to convert the HTML into MD, i did it using Turndown like your looking into, i did create a devapp tool that migrated from WP into StudioCMS, whihc you can use as a reference for building your helpers, just ignore all the DB related stuff to get the data. https://github.com/withstudiocms/studiocms/blob/50d2916c8a80ecca0c5b684ea9b146e8bc60d43b/packages/studiocms_devapps/src/utils/wp-api/converters.ts#L50
As for rendering external Markdown in Astro, there is a few options,
- Build your own using something like marked.js
@astropup/mdhas a Mardown rendering toolastro-remote- allows making remote HTML and MD easy@studiocms/markdown-remark- Astro-like markdown renderer that follows closely to the output standard astro would render with local markdown.
Also another project to checkout, is dewp which lets you pull the WP content in using the Astro Content Layer
HTML is not the same as markdown. they are different languages
Wordpress itself does not use Markdown for its data structure.... it actually stores HTML.
I found this out when building a wordpress migrator for StudioCMS
Where in StudioCMS i store raw markdown in the database, then convert it to html during runtime
I would try using dewp, as it turns WP into a headless CMS and provides you direct access using the astro content collections system, instead of you having to make your own helpers