[Fix] Using local styles instead of fetching them

feature/custom-highlight-themes
Marco Kutscha 2024-02-24 13:26:06 +01:00
parent 5c82d48f44
commit 2db69add1d
3 changed files with 5 additions and 1 deletions

View File

@ -11,3 +11,4 @@ build_server:
make_static_files: make_static_files:
cp -r snap-client/build snap-server/public cp -r snap-client/build snap-server/public
cp -r snap-client/node_modules/highlight.js/styles/ snap-server/public/

View File

@ -74,7 +74,9 @@ function App() {
const theme = config?.highlight_theme ?? DEFAULT_THEME; const theme = config?.highlight_theme ?? DEFAULT_THEME;
const cssLink = document.createElement("link"); const cssLink = document.createElement("link");
cssLink.rel = "stylesheet"; cssLink.rel = "stylesheet";
cssLink.href = "https://cdn.jsdelivr.net/npm/highlight.js/styles/" + theme + ".css";
// add a ref to node_modules/highlight.js/styles/{theme}.css so you dont have to get it from the internet
cssLink.href = `./styles/${theme}.css`;
document.head.appendChild(cssLink); document.head.appendChild(cssLink);
return () => { return () => {
document.head.removeChild(cssLink); document.head.removeChild(cssLink);

View File

@ -50,6 +50,7 @@ async fn main() -> std::io::Result<()> {
.service(web::resource("/").to(root)) .service(web::resource("/").to(root))
.service(Files::new("/public", "./public")) .service(Files::new("/public", "./public"))
.service(Files::new("/static", "./public/static")) .service(Files::new("/static", "./public/static"))
.service(Files::new("/styles", "./public/styles"))
}) })
.bind(("127.0.0.1", available_port))? .bind(("127.0.0.1", available_port))?
.run() .run()