Customizable live demos (renderers?) via codefences with "meta" tags #3676
Unanswered
NullVoxPopuli
asked this question in
Q&A
Replies: 2 comments 2 replies
-
Write a markdown-it plugin (add it via markdown.config) and return a vue component from it. Let me know if you need help regarding the mdit part (it'll be ~5 line code IG). More context on vue part - Say you register a component named |
Beta Was this translation helpful? Give feedback.
2 replies
-
I've created a custom theme called genji-theme-vitepress to achieve a similar effect: ```js eval code=false
size = Inputs.range([50, 300], { label: "size", value: 100, step: 1 });
```
```js eval
(() => {
const div = document.createElement("div");
div.style.width = size + "px";
div.style.height = "100px";
div.style.background = "orange";
return div;
})();
``` This will produce: I'd love for you to try it out and share your feedback with me! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Is your feature request related to a problem? Please describe.
Vitepress offers a lot, but it doesn't allow any live demo support from the markdown.
For example, in my own experiments, I use the
live
tag to denote something should be rendered:Closest thing I've seen is https://vitepress.dev/reference/default-theme-search#custom-content-renderer
but that would require emitting a script tag in the HTML -- which... is maybe the best we can do with SSG?
Describe the solution you'd like
have a way to hook in to code fences, with a
live
meta tag, and have them render.I've done some thinking over here: NullVoxPopuli/limber#1632,
the return value could be a VueComponent, since VitePress is in Vue .. but i guess.. is there any Vue left over at run time?
maybe a script tag is the only way to move forward :think
Describe alternatives you've considered
Additional context
thanks! vitepress is great!
Validations
Beta Was this translation helpful? Give feedback.
All reactions