-
How do I generate Markdown that gets interpreted into the page from within a JS code block within an index.md file? For example, from within a JS code block, this: ["cat", "dog", "bat"].map(k => `1. ${k}`).join("\n") shows up in the page as:
but what i need is:
I want the built-in Markdown to process it, including applying any extensions like I know that Page Loaders emit Markdown that gets interpreted, but that is not what I need. Tried many approaches, yet failed. Please enlighten me and untangle my brain. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
you could use markdown-it as a client library. |
Beta Was this translation helpful? Give feedback.
-
To add to @Fil’s answer, you can use markdown-it on the client, and upvote #895 if you are interested in this feature. We don’t yet provide a Therefore to generate content on the client, we recommend instead using Hypertext Literal which is available as the Lastly you can use page loaders to generate Markdown at build time which is probably the best user experience for this use case because the content is rendered statically, searchable, with no reflow or delay on load, etc. We are also working on page fragment loaders in #1807 that will make it easier for part of the page to be generated at build time without needing to move the whole page into a page loader. |
Beta Was this translation helpful? Give feedback.
you could use markdown-it as a client library.
https://observablehq.observablehq.cloud/pangea/party/markdown-it