[Feat] add preview_title option to configure preview page title (#20)

* [Feat] add preview_title option

* [Update] add preview_title option in document
pull/21/head
Mist 2024-02-24 18:26:03 +08:00 committed by GitHub
parent a11ac2246d
commit 7963b3f2cc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 14 additions and 15 deletions

2
.gitignore vendored
View File

@ -19,4 +19,4 @@ node_modules
# build # build
output.css output.css
public snap-server/public

View File

@ -57,9 +57,10 @@ require("codesnap").setup({...})
There is a default config: There is a default config:
```lua ```lua
{ {
mac_window_bar = true, -- MacOS style title bar switch mac_window_bar = true,-- (Optional) MacOS style title bar switch
opacity = true, -- The code snap has some opacity by default, set it to false for 100% opacity opacity = true, -- (Optional) The code snap has some opacity by default, set it to false for 100% opacity
watermark = "CodeSnap.nvim" -- (Optional) you can custom your own watermark, but if you don't like it, just set it to "" watermark = "CodeSnap.nvim" -- (Optional) you can custom your own watermark, but if you don't like it, just set it to ""
preview_title = "CodeSnap.nvim" -- (Optional) preview page title
} }
``` ```

View File

@ -5,6 +5,7 @@ return {
mac_window_bar = true, mac_window_bar = true,
opacity = true, opacity = true,
watermark = "CodeSnap.nvim", watermark = "CodeSnap.nvim",
preview_title = "CodeSnap.nvim",
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("(.*[/\\])"))),

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

View File

@ -1,21 +1,11 @@
{ {
"short_name": "React App", "short_name": "CdeoSnap.nvim",
"name": "Create React App Sample", "name": "CodeSnap.nvim",
"icons": [ "icons": [
{ {
"src": "favicon.ico", "src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16", "sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon" "type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
} }
], ],
"start_url": ".", "start_url": ".",

View File

@ -8,6 +8,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";
function App() { function App() {
const [socketUrl] = useState(`ws://${getWebsocketHost()}/ws`); const [socketUrl] = useState(`ws://${getWebsocketHost()}/ws`);
@ -64,6 +65,10 @@ function App() {
notifyCopyCommand(); notifyCopyCommand();
}, [event, readyState, notifyCopyCommand]); }, [event, readyState, notifyCopyCommand]);
useEffect(() => {
document.title = config?.preview_title ?? PREVIEW_TITLE_PLACEHOLDER;
}, []);
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">

View File

@ -5,6 +5,7 @@ export interface Config {
opacity: boolean; opacity: boolean;
watermark: string; watermark: string;
auto_load: boolean; auto_load: boolean;
preview_title: string;
} }
const CONFIG_STORAGE_KEY = "CONFIG_STORAGE_KEY"; const CONFIG_STORAGE_KEY = "CONFIG_STORAGE_KEY";

View File

@ -6,6 +6,7 @@ pub struct Config {
opacity: bool, opacity: bool,
watermark: Option<String>, watermark: Option<String>,
auto_load: bool, auto_load: bool,
preview_title: String,
} }
impl From<&str> for Config { impl From<&str> for Config {