Trying to add syntax highlighting for code
All checks were successful
Build Tavernworks / Explore-Gitea-Actions (push) Successful in 2m49s

This commit is contained in:
2026-01-13 22:54:05 -05:00
parent 53e62fcb68
commit dae46e3cdf
3 changed files with 15 additions and 1 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "bard"
version = "0.3.17"
version = "0.3.18"
edition = "2024"
description = "Dioxus components that will display a Tavern blogging system Blog."
repository = "/CyberMages/tavern"

View File

@ -128,6 +128,16 @@ pub fn PostHeader(tale: Tale, adventurer: Option<Adventurer>) -> Element
#[component]
pub fn Story(text: String) -> Element
{
use_effect(||
{
spawn(async
{
document::eval("hljs.highlightAll();")
.await
.expect("Error highlighting code");
});
});
rsx!
{
div

View File

@ -45,6 +45,10 @@ fn BlogLayout() -> Element
}
}
// Setup the system to use Highlight.js for code blocks.
document::Stylesheet { href: "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/styles/vs2015.css" }
document::Script { src: "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/highlight.min.js" }
Outlet::<Page> {}
}
}