this repo has no description
1"use strict"
2//let base = new URL("./", document.baseURI)
3let pages = [
4 ["Demo", 'index.html'],
5 ["Tests", 'testing/index.html'],
6]
7function make_link([title, url]) {
8 let a = document.createElement('a')
9 a.href = new URL("../"+url, document.currentScript.src)
10 a.textContent = title
11 if (a.pathname == window.location.pathname)
12 a.classList.add('current')
13 return a
14}
15let nav = document.createElement('nav')
16nav.append(...pages.map(make_link))
17document.currentScript.replaceWith(nav)
18
19let style = document.createElement('style')
20style.textContent = `
21nav {
22 display: flex;
23 gap: 0.5em;
24 font: 1em sans-serif;
25 align-items: start;
26 margin-bottom: 8px;
27}
28nav > a {
29 border: 3px solid;
30 border-color: currentColor transparent;
31 text-decoration: none;
32 padding: 0 0.5em;
33 font-weight: bold;
34}
35nav > a.current {
36 color: gray;
37 border: 3px dotted gray;
38}
39`
40document.head.append(style)