feat: add dark/light theme.

This commit is contained in:
jaywcjlove
2022-10-01 02:29:00 +08:00
parent cc877c2c3c
commit 53de582bb9
6 changed files with 198 additions and 121 deletions

View File

@ -1,18 +1,22 @@
import path from 'path';
import { github, editor } from './logo.mjs';
import { getSVGNode } from '../utils/getSVGNode.mjs';
import { darkMode } from '../utils/darkMode.mjs';
const ICONS_PATH = path.resolve(process.cwd(), 'scripts/assets/quickreference.svg')
export function header({ homePath, githubURL = '' }) {
const svgNode = getSVGNode(ICONS_PATH)
const data = [
{
menu: true,
href: githubURL,
target: '__blank',
label: '编辑',
children: [editor]
},
...darkMode(),
{
menu: true,
href: 'https://github.com/jaywcjlove/reference',
target: '__blank',
children: [github]
@ -59,7 +63,8 @@ export function header({ homePath, githubURL = '' }) {
properties: {
class: ['menu'],
},
children: data.map(({ href, label, children = [], ...props }) => {
children: data.map(({ href, label, menu, children = [], ...props }) => {
if (!menu) return { children, ...props };
const childs = {
type: 'element',
tagName: 'a',