#rendering markdown strings
3 messages · Page 1 of 1 (latest)
Hi @drifting path. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
Astro does not include built-in support for rendering remote Markdown strings. To fetch remote Markdown and render it to HTML, you will need to install and configure your own Markdown parser from npm. This will not inherit from any of Astro’s built-in Markdown and MDX settings that you have configured. Be sure that you understand these limitations before implementing this in your project.
Here's an example of fetching remote Markdown and rendering it using the "marked" library:
---
// Example: Fetch Markdown from a remote API
// and render it to HTML, at runtime.
// Using "marked" (https://github.com/markedjs/marked)
import { marked } from 'marked';
const response = await fetch('https://raw.githubusercontent.com/wiki/adam-p/markdown-here/Markdown-Cheatsheet.md');
const markdown = await response.text();
const content = marked.parse(markdown);
---
<article set:html={content} />
This example is taken from the Fetching Remote Markdown (https://docs.astro.build/en/guides/markdown-content#fetching-remote-markdown) section of the Astro documentation.