forked from mirror/codesnap.nvim
Compare commits
3 commits
main
...
feature/cu
Author | SHA1 | Date | |
---|---|---|---|
|
5f74fef0ed | ||
|
2db69add1d | ||
|
5c82d48f44 |
8 changed files with 19 additions and 1 deletions
|
@ -63,6 +63,7 @@ There is a default config:
|
||||||
preview_title = "CodeSnap.nvim", -- (Optional) preview page title
|
preview_title = "CodeSnap.nvim", -- (Optional) preview page title
|
||||||
editor_font_family = "CaskaydiaCove Nerd Font", -- (Optional) preview code font family
|
editor_font_family = "CaskaydiaCove Nerd Font", -- (Optional) preview code font family
|
||||||
watermark_font_family = "Pacifico", -- (Optional) watermark font family
|
watermark_font_family = "Pacifico", -- (Optional) watermark font family
|
||||||
|
highlight_theme = "atom-one-dark", -- (Optional) theme for code highlights
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ return {
|
||||||
preview_title = "CodeSnap.nvim",
|
preview_title = "CodeSnap.nvim",
|
||||||
editor_font_family = "CaskaydiaCove Nerd Font",
|
editor_font_family = "CaskaydiaCove Nerd Font",
|
||||||
watermark_font_family = "Pacifico",
|
watermark_font_family = "Pacifico",
|
||||||
|
highlight_theme = "atom-one-dark",
|
||||||
auto_load = true,
|
auto_load = true,
|
||||||
},
|
},
|
||||||
cwd = path_utils.back(path_utils.back(debug.getinfo(1, "S").source:sub(2):match("(.*[/\\])"))),
|
cwd = path_utils.back(path_utils.back(debug.getinfo(1, "S").source:sub(2):match("(.*[/\\])"))),
|
||||||
|
|
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/
|
||||||
|
|
|
@ -9,6 +9,7 @@ import { getWebsocketHost } from "./utils";
|
||||||
const CODE_EMPTY_PLACEHOLDER = `print "Hello, CodeSnap.nvim!"`;
|
const CODE_EMPTY_PLACEHOLDER = `print "Hello, CodeSnap.nvim!"`;
|
||||||
const WATER_MARK_PLACEHOLDER = "CodeSnap.nvim";
|
const WATER_MARK_PLACEHOLDER = "CodeSnap.nvim";
|
||||||
const PREVIEW_TITLE_PLACEHOLDER = "CodeSnap.nvim";
|
const PREVIEW_TITLE_PLACEHOLDER = "CodeSnap.nvim";
|
||||||
|
const DEFAULT_THEME = "atom-one-dark";
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const [socketUrl] = useState(`ws://${getWebsocketHost()}/ws`);
|
const [socketUrl] = useState(`ws://${getWebsocketHost()}/ws`);
|
||||||
|
@ -69,6 +70,18 @@ function App() {
|
||||||
document.title = config?.preview_title ?? PREVIEW_TITLE_PLACEHOLDER;
|
document.title = config?.preview_title ?? PREVIEW_TITLE_PLACEHOLDER;
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const theme = config?.highlight_theme ?? DEFAULT_THEME;
|
||||||
|
const cssLink = document.createElement("link");
|
||||||
|
cssLink.rel = "stylesheet";
|
||||||
|
cssLink.href = `./styles/${theme}.css`;
|
||||||
|
document.head.appendChild(cssLink);
|
||||||
|
return () => {
|
||||||
|
document.head.removeChild(cssLink);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
, [config?.highlight_theme]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-full h-full flex flex-col items-center bg-deep-gray">
|
<div className="w-full h-full flex flex-col items-center bg-deep-gray">
|
||||||
<p className="rainbow-text text-4xl font-extrabold mt-20">
|
<p className="rainbow-text text-4xl font-extrabold mt-20">
|
||||||
|
|
|
@ -8,6 +8,7 @@ export interface Config {
|
||||||
preview_title: string;
|
preview_title: string;
|
||||||
watermark_font_family: string;
|
watermark_font_family: string;
|
||||||
editor_font_family: string;
|
editor_font_family: string;
|
||||||
|
highlight_theme: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CONFIG_STORAGE_KEY = "CONFIG_STORAGE_KEY";
|
const CONFIG_STORAGE_KEY = "CONFIG_STORAGE_KEY";
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import ReactDOM from "react-dom/client";
|
import ReactDOM from "react-dom/client";
|
||||||
import "./output.css";
|
import "./output.css";
|
||||||
import "highlight.js/styles/atom-one-dark.css";
|
|
||||||
import App from "./app";
|
import App from "./app";
|
||||||
import reportWebVitals from "./reportWebVitals";
|
import reportWebVitals from "./reportWebVitals";
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ pub struct Config {
|
||||||
preview_title: String,
|
preview_title: String,
|
||||||
watermark_font_family: String,
|
watermark_font_family: String,
|
||||||
editor_font_family: String,
|
editor_font_family: String,
|
||||||
|
highlight_theme: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&str> for Config {
|
impl From<&str> for Config {
|
||||||
|
|
|
@ -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 a new issue