Crates.io | pagetop-hljs |
lib.rs | pagetop-hljs |
version | 0.0.14 |
source | src |
created_at | 2023-07-06 18:30:06.744406 |
updated_at | 2024-07-28 18:01:16.786811 |
description | PageTop package to display beautiful code snippets on web pages. |
homepage | https://pagetop.cillero.es |
repository | https://github.com/manuelcillero/pagetop-hljs |
max_upload_size | |
id | 910179 |
size | 611,928 |
language-
and lang-
class prefixes.Add pagetop-hljs
to your Cargo.toml
:
[dependencies]
pagetop-hljs = "<Version>"
Add pagetop_hljs::HighlightJS
to your dependencies package:
use pagetop::prelude::*;
impl PackageTrait for MyPackage {
// ...
fn dependencies(&self) -> Vec<PackageRef> {
vec![
// ...
&pagetop_hljs::HighlightJS,
// ...
]
}
fn configure_service(&self, cfg: &mut service::web::ServiceConfig) {
cfg.route("/", service::web::get().to(hljs_sample));
}
// ...
}
And put your code snippets on web pages:
use pagetop_hljs::prelude::*;
#[service::get("/")]
async fn hljs_sample(request: HttpRequest) -> ResultPage<Markup, ErrorPage> {
Page::new(request)
.with_component(Snippet::with(
HljsLang::Rust,
r###"
// This is the main function.
fn main() {
// Print text to the console.
println!("Hello World!");
}
"###,
))
.render()
}
PageTop is an opinionated web framework to build modular Server-Side Rendering web solutions.
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.
All code in this project is dual-licensed under either:
MIT License (LICENSE-MIT or https://opensource.org/licenses/MIT)
Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
at your option. This means you can select the license you prefer! This dual-licensing approach is the de-facto standard in the Rust ecosystem.