Skip to content

Commit c052882

Browse files
committed
Move What's New to top of sidebar nav above Libraries
1 parent 800e0bd commit c052882

1 file changed

Lines changed: 14 additions & 20 deletions

File tree

assets/nav.js

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@
55
const isRoot = parts.length === 0 || (parts.length === 1 && parts[0] === 'index.html');
66
const prefix = isRoot ? '/' : '../';
77

8-
function isActive(name) { return path.includes('/' + name); }
9-
function link(name, label, extra) {
10-
const active = isActive(name) ? ' class="active"' : '';
11-
if (extra) return `<a href="${prefix}${name}"${active} style="${extra}">${label}</a>`;
12-
return `<a href="${prefix}${name}"${active}>${label}</a>`;
8+
function isActive(name) {
9+
if (name === 'libraries#whats-new') return false;
10+
return path.includes('/' + name);
11+
}
12+
13+
function link(href, label, style) {
14+
const active = isActive(href) ? ' class="active"' : '';
15+
const s = style ? ` style="${style}"` : '';
16+
return `<a href="${prefix}${href}"${active}${s}>${label}</a>`;
1317
}
1418

1519
const nav = document.getElementById('site-nav');
@@ -32,12 +36,12 @@
3236
const sidebar = document.getElementById('site-sidebar') || document.querySelector('.sidebar');
3337
if (sidebar) {
3438
sidebar.innerHTML = `
39+
${link('libraries#whats-new', "What's New", 'color:#e8b400;font-weight:700;')}
40+
<div style="height:1px;background:#e0e0e0;margin:0.5rem 0;"></div>
3541
${link('libraries', 'Libraries')}
3642
${link('reference', 'Reference')}
3743
${link('examples', 'Examples')}
3844
${link('about', 'About')}
39-
<div style="height:1px;background:#e0e0e0;margin:0.75rem 0;"></div>
40-
${link('libraries#whats-new', "What's New", 'color:#e8b400;font-weight:600;font-size:13px;')}
4145
`;
4246
}
4347

@@ -69,16 +73,8 @@
6973
flex-direction: column;
7074
line-height: 1.15;
7175
}
72-
.nav-title-top {
73-
font-size: 13px;
74-
font-weight: 700;
75-
color: #e8b400;
76-
}
77-
.nav-title-bottom {
78-
font-size: 13px;
79-
font-weight: 700;
80-
color: #e8b400;
81-
}
76+
.nav-title-top { font-size: 13px; font-weight: 700; color: #e8b400; }
77+
.nav-title-bottom { font-size: 13px; font-weight: 700; color: #e8b400; }
8278
.hamburger {
8379
background: none;
8480
border: none;
@@ -88,9 +84,7 @@
8884
display: none;
8985
margin-left: 0.5rem;
9086
}
91-
@media (max-width: 768px) {
92-
.hamburger { display: block; }
93-
}
87+
@media (max-width: 768px) { .hamburger { display: block; } }
9488
`;
9589
document.head.appendChild(style);
9690
}

0 commit comments

Comments
 (0)