.github
.husky
docs
scripts
assets
nodes
footer.mjs
header.mjs
htmlTagAddAttri.mjs
logo.mjs
utils
build.mjs
create.mjs
index.mjs
style.css
watch.mjs
.gitignore
.lintstagedrc
.prettierignore
.prettierrc
CONTRIBUTING.md
Dockerfile
LICENSE
README.md
package.json
renovate.json
101 lines
2.6 KiB
JavaScript
101 lines
2.6 KiB
JavaScript
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],
|
|
},
|
|
];
|
|
return {
|
|
type: 'element',
|
|
tagName: 'nav',
|
|
properties: {
|
|
class: 'header-nav',
|
|
},
|
|
children: [
|
|
{
|
|
type: 'element',
|
|
tagName: 'div',
|
|
properties: {
|
|
class: ['max-container'],
|
|
},
|
|
children: [
|
|
{
|
|
type: 'element',
|
|
tagName: 'a',
|
|
properties: {
|
|
href: homePath,
|
|
class: ['logo'],
|
|
},
|
|
children: [
|
|
...svgNode,
|
|
{
|
|
type: 'element',
|
|
tagName: 'span',
|
|
properties: {
|
|
class: ['title'],
|
|
},
|
|
children: [{ type: 'text', value: 'Quick Reference' }],
|
|
},
|
|
],
|
|
},
|
|
{
|
|
type: 'element',
|
|
tagName: 'div',
|
|
properties: {
|
|
class: ['menu'],
|
|
},
|
|
children: data.map(({ href, label, menu, children = [], ...props }) => {
|
|
if (!menu) return { children, ...props };
|
|
const childs = {
|
|
type: 'element',
|
|
tagName: 'a',
|
|
properties: { href, class: [], ...props },
|
|
children: [
|
|
...children,
|
|
{
|
|
type: 'element',
|
|
tagName: 'span',
|
|
properties: {},
|
|
children: label ? [{ type: 'text', value: label }] : [],
|
|
},
|
|
],
|
|
};
|
|
if (label) {
|
|
childs.children = [
|
|
...children,
|
|
{
|
|
type: 'element',
|
|
tagName: 'span',
|
|
properties: {},
|
|
children: [{ type: 'text', value: label }],
|
|
},
|
|
];
|
|
} else {
|
|
childs.children = children;
|
|
}
|
|
return childs;
|
|
}),
|
|
},
|
|
],
|
|
},
|
|
],
|
|
};
|
|
}
|