[Fix] Using local styles instead of fetching them
parent
5c82d48f44
commit
2db69add1d
1
makefile
1
makefile
|
@ -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/
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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()
|
||||||
|
|
Loading…
Reference in New Issue