Skip to content

Commit

Permalink
website: custom nav menus. #102
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Nov 22, 2022
1 parent aadf975 commit ead5d35
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 5 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@uiw/formatter": "^1.3.3",
"@wcj/markdown-to-html": "^2.2.0",
"chokidar": "^3.5.3",
"dotenv": "^16.0.3",
"fs-extra": "^10.1.0",
"husky": "^8.0.1",
"lint-staged": "^13.0.3",
Expand Down
21 changes: 20 additions & 1 deletion scripts/nodes/header.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
import path from 'path';
import { github, editor } from './logo.mjs';
import * as dotenv from 'dotenv';
import { github, editor, home } from './logo.mjs';
import { getSVGNode } from '../utils/getSVGNode.mjs';
import { darkMode } from '../utils/darkMode.mjs';

dotenv.config();

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 getReferrals() {
const url = process.env.REF_URL;
const label = process.env.REF_LABEL;
if (!url || !label) return [];
return [
{
menu: true,
href: url,
target: '__blank',
label: label,
children: [home],
},
];
}

export function header({ homePath, githubURL = '', isHome } = {}) {
const svgNode = getSVGNode(ICONS_PATH);
const svgSearchNode = getSVGNode(ICONS_SEARCH_PATH);
Expand Down Expand Up @@ -43,6 +61,7 @@ export function header({ homePath, githubURL = '', isHome } = {}) {
},
],
},
...getReferrals(),
{
menu: true,
href: githubURL,
Expand Down
20 changes: 20 additions & 0 deletions scripts/nodes/logo.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,23 @@ export const editor = {
},
],
};

export const home = {
type: 'element',
tagName: 'svg',
properties: {
viewBox: '0 0 24 24',
fill: 'currentColor',
height: '1em',
width: '1em',
},
children: [
{
type: 'element',
tagName: 'path',
properties: {
d: 'M12.74 2.32a1 1 0 0 0-1.48 0l-9 10A1 1 0 0 0 3 14h2v7a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-7h2a1 1 0 0 0 1-1 1 1 0 0 0-.26-.68z',
},
},
],
};
8 changes: 4 additions & 4 deletions scripts/style/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -527,10 +527,10 @@ a.text-grey {

.header-nav .menu a,
.header-nav .menu button {
padding-left: 0.75rem;
padding-right: 0.75rem;
padding-top: 0.5rem;
padding-bottom: 0.5rem;
padding-left: 0.55rem;
padding-right: 0.55rem;
padding-top: 0.4rem;
padding-bottom: 0.4rem;
border-radius: 9999px;
transition: all 0.3s;
border: 0;
Expand Down

0 comments on commit ead5d35

Please sign in to comment.