From 2db69add1d0ed0ac0449d21d47a452fef12560d6 Mon Sep 17 00:00:00 2001 From: Marco Kutscha Date: Sat, 24 Feb 2024 13:26:06 +0100 Subject: [PATCH] [Fix] Using local styles instead of fetching them --- makefile | 1 + snap-client/src/app.tsx | 4 +++- snap-server/src/main.rs | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/makefile b/makefile index 312fbfe..f1e0024 100644 --- a/makefile +++ b/makefile @@ -11,3 +11,4 @@ build_server: make_static_files: cp -r snap-client/build snap-server/public + cp -r snap-client/node_modules/highlight.js/styles/ snap-server/public/ diff --git a/snap-client/src/app.tsx b/snap-client/src/app.tsx index ebb7e35..04d0a93 100644 --- a/snap-client/src/app.tsx +++ b/snap-client/src/app.tsx @@ -74,7 +74,9 @@ function App() { const theme = config?.highlight_theme ?? DEFAULT_THEME; const cssLink = document.createElement("link"); 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); return () => { document.head.removeChild(cssLink); diff --git a/snap-server/src/main.rs b/snap-server/src/main.rs index a922cd9..5891235 100644 --- a/snap-server/src/main.rs +++ b/snap-server/src/main.rs @@ -50,6 +50,7 @@ async fn main() -> std::io::Result<()> { .service(web::resource("/").to(root)) .service(Files::new("/public", "./public")) .service(Files::new("/static", "./public/static")) + .service(Files::new("/styles", "./public/styles")) }) .bind(("127.0.0.1", available_port))? .run()