website: add search feature. #32

This commit is contained in:
jaywcjlove
2022-11-20 03:26:06 +08:00
parent 9290c65fdc
commit 3bd4114c63
12 changed files with 516 additions and 84 deletions

View File

@ -1,21 +1,6 @@
import path from 'path';
import { getSVGNode } from './getSVGNode.mjs';
const scripts = `
const LOCAL_NANE = '_dark_mode_theme_'
const rememberedValue = localStorage.getItem(LOCAL_NANE);
if (rememberedValue && ['light', 'dark'].includes(rememberedValue)) {
document.documentElement.setAttribute('data-color-mode', rememberedValue);
}
const button = document.querySelector('#darkMode');
button.onclick = () => {
const theme = document.documentElement.dataset.colorMode;
const mode = theme === 'light' ? 'dark' : 'light';
document.documentElement.setAttribute('data-color-mode', mode);
localStorage.setItem(LOCAL_NANE, mode);
}
`;
const ICONS_PATH = path.resolve(process.cwd(), 'scripts/assets');
export function darkMode() {
@ -33,15 +18,5 @@ export function darkMode() {
},
children: [...sunNode, ...moonNode],
},
{
type: 'element',
tagName: 'script',
children: [
{
type: 'text',
value: scripts,
},
],
},
];
}