How to inject reactive components into static HTML content #2385
-
I'm trying to render a book (source will be in AsciiDoc) with reactive components inside. This basically the same issue MDX solves, but for AsciiDoc instead of markdown. I'm able to render the AsciiDoc content as an HTML string during the build process, but if the rendered content includes a placeholder like Or would the entire book content need to be converted to a SolidJS component instead of an HTML string...? I'm not sure how I would achieve that. I could, of course, do something like... <div innerHTML={bookContent} /> But then how would I mount the reactive components? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
For that, you need an mdx-based solution. |
Beta Was this translation helpful? Give feedback.
-
I'm over thinking this. If save the string with this format: `export default Content() {
return (
${escapedHTMLFromAsciiDoc}
)
}` ...to a temp file, and then load it directly using Maybe not the prettiest solution, but I don't need pretty. If you don't the asciidoc file (I don't), you would have to be very careful with how you escape the html content, since with SSR it's running on the server. |
Beta Was this translation helpful? Give feedback.
I'm over thinking this. If save the string with this format:
...to a temp file, and then load it directly using
await import(tmpFile)
, it should work.Maybe not the prettiest solution, but I don't need pretty.
If you don't the asciidoc file (I don't), you would have to be very careful with how you escape the html content, since with SSR it's running on the server.