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

@ -4,9 +4,45 @@ import { getSVGNode } from '../utils/getSVGNode.mjs';
import { darkMode } from '../utils/darkMode.mjs';
const ICONS_PATH = path.resolve(process.cwd(), 'scripts/assets/quickreference.svg');
const ICONS_SEARCH_PATH = path.resolve(process.cwd(), 'scripts/assets/search.svg');
export function header({ homePath, githubURL = '' }) {
const svgNode = getSVGNode(ICONS_PATH);
const svgSearchNode = getSVGNode(ICONS_SEARCH_PATH);
const data = [
{
menu: true,
href: 'javascript:void(0);',
class: ['searchbtn'],
id: 'searchbtn',
children: [
...svgSearchNode,
{
type: 'element',
tagName: 'span',
children: [
{
type: 'text',
value: '搜索',
},
],
},
{
type: 'element',
tagName: 'span',
children: [
{
type: 'text',
value: '⌘',
},
{
type: 'text',
value: 'K',
},
],
},
],
},
{
menu: true,
href: githubURL,