HighlightJS (pagetop-hljs) is a PageTop module that displays beautiful code snippets on web pages using the versatile highlight.js JavaScript library.

Usage

Add to Cargo.toml dependency to pagetop-hljs:

rust [dependencies] pagetop-hljs = "<Version>"

Add the dependency to pagetop_hljs::HighlightJS in the module that uses it:

```rust use pagetop::prelude::*;

impl ModuleTrait for ModuleName { // ... fn dependencies(&self) -> Vec { vec![ // ... &pagetop_hljs::HighlightJS // ... ] } // ... } ```

Now your module can add code snippets on web pages:

```rust use pagetop_hljs::prelude::*;

[service::get("/")]

async fn hljssample(request: service::HttpRequest) -> ResultPage { Page::new(request) .within( "content", Snippet::with( HljsLang::Rust, r##" async fn helloworld(request: service::HttpRequest) -> ResultPage { Page::new(request) .within("content", Html::with(html! { h1 { "Hello World!" } })) .render() } "##, ), ) .render() } ```

Note

HighlightJS uses ActionBeforeRenderPage with a weight of 99 to add page assets. If you use this action to alter HighlightJS rendering, such as specifying the theme for snippets, please ensure that your action has a weight lower than 99. Default 0 is ok.

📦 About PageTop

PageTop is an opinionated web development framework that uses some of the most stable and popular Rust packages to build modular, extensible and configurable Server-Side Rendering (SSR) solutions.

🚧 Warning

PageTop framework is currently in active development. The API is unstable and subject to frequent changes. Production use is not recommended until version 0.1.0.

📜 License

This project is licensed under either of the following licenses, at your option: