#what is the best way to render external markdown in astro?

28 messages · Page 1 of 1 (latest)

safe pelican
#

just that.
i tried marked.js but not work properly
i fetching data from a headless-cms wordpress

safe pelican
#

supposed to be

keen heart
#

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/md has a Mardown rendering tool
  • astro-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.
safe pelican
#

is not html is markdown

#

what do you recomend?

keen heart
safe pelican
keen heart
safe pelican
#

yes i try to mean that

#

sorry for my english

keen heart
#

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

safe pelican
#

but i send just like that

keen heart
safe pelican
#

but when i print in console it prints good, idk why marked is not working correctly

#

i don't think wp it's the problem

safe pelican
#

i think is tailwind aajajajajaaja

#

i just added styles for li