mirror of
https://github.com/jaywcjlove/reference.git
synced 2025-06-17 20:51:21 +08:00
website: update dark theme issue.
This commit is contained in:
@ -3,11 +3,13 @@ import { getSVGNode } from './getSVGNode.mjs';
|
||||
|
||||
const ICONS_PATH = path.resolve(process.cwd(), 'scripts/assets');
|
||||
|
||||
export function darkMode() {
|
||||
export function darkMode({ homePath = '', isHome } = {}) {
|
||||
const relativePath = homePath.replace(/\/?index.html$/, isHome ? '' : '/');
|
||||
const iconSunPath = path.resolve(ICONS_PATH, `sun.svg`);
|
||||
const iconMoonPath = path.resolve(ICONS_PATH, `moon.svg`);
|
||||
const sunNode = getSVGNode(iconSunPath);
|
||||
const moonNode = getSVGNode(iconMoonPath);
|
||||
const darkJSUrl = relativePath + 'js/dark.js';
|
||||
return [
|
||||
{
|
||||
type: 'element',
|
||||
@ -18,5 +20,12 @@ export function darkMode() {
|
||||
},
|
||||
children: [...sunNode, ...moonNode],
|
||||
},
|
||||
{
|
||||
type: 'element',
|
||||
tagName: 'script',
|
||||
properties: {
|
||||
src: darkJSUrl,
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
Reference in New Issue
Block a user