A zero-config but extendable markdown component for leptos.
It supports commonmark, and so much more.
leptos-markdown
is not published on crates.io yet.
Use it as a git dependency !
# inside Cargo.toml
leptos-markdown = {git="https://github.com/rambip/leptos-markdown"}
You can use this component to render both static and dynamic markdown.
use leptos::*;
use leptos_markdown::Markdown;
{
...
view!{cx,
<Markdown src="# Markdown Power !"/>
}
}
{
...
let (content, set_content) = create_signal(cx, "# Markdown Power !".to_string());
view!{cx,
<Markdown src=content/>
}
}
To build them, just follow the leptos installation instructions and run trunk serve
to try them.
./examples/showcase
You can see the result here
To be fair, this is not the vanilla component, there is a bit of styling added.
./examples/editor
There is a demo of an interactive editor here
./examples/onclick/
Illustrates a cool feature of this crate: onclick
events for any rendered content
Try it here
This feature is still very experimental. But there is an exemple here
I already built a similar library using yew here This project was great to compare the advantages and drawbacks of the two major rust web frameworks !
see my feedback for a comparison