Skip to content

rambip/leptos-markdown

Repository files navigation

A zero-config but extendable markdown component for leptos.

It supports commonmark, and so much more.

Installation

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"}

Usage

You can use this component to render both static and dynamic markdown.

Static markdown

use leptos::*;
use leptos_markdown::Markdown;

{
    ...
    view!{cx,
        <Markdown src="# Markdown Power !"/>
    }
}

Dynamic markdown

{
    ...
    let (content, set_content) = create_signal(cx, "# Markdown Power !".to_string());

    view!{cx,
        <Markdown src=content/>
    }
}

Examples

To build them, just follow the leptos installation instructions and run trunk serve to try them.

Showcase

./examples/showcase

You can see the result here

To be fair, this is not the vanilla component, there is a bit of styling added.

Editor

./examples/editor

There is a demo of an interactive editor here

Onclick

./examples/onclick/

Illustrates a cool feature of this crate: onclick events for any rendered content

Try it here

Custom components

This feature is still very experimental. But there is an exemple here

Comparison

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

About

A zero-config leptos component to display markdown

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published