Begin docs layout of new design

This commit is contained in:
Matthew Holt 2023-05-02 17:29:08 -06:00
parent c5b7a286ce
commit 48111ebb9d
No known key found for this signature in database
GPG key ID: 2A349DD577D586A5
14 changed files with 1902 additions and 321 deletions

23
new/resources/js/docs.js Normal file
View file

@ -0,0 +1,23 @@
ready(function() {
// highlight current page in left nav
let currentPageLink = $('main nav a[href="'+window.location.pathname+'"]');
if (window.location.pathname.startsWith("/docs/json/")) {
// as a special case, highlight the JSON structure link anywhere within it
currentPageLink = $('main nav a[href="/docs/json/"]');
}
if (window.location.pathname.startsWith("/docs/modules/")) {
// as another special case, highlight the modules link anywhere within it
currentPageLink = $('main nav a[href="/docs/modules/"]');
}
currentPageLink?.classList?.add('current');
// add anchor links, inspired by https://github.com/bryanbraun/anchorjs
$$('article > h2[id], article > h3[id], article > h4[id], article > h5[id], article > h6[id]').forEach(function(elem) {
const anchor = document.createElement('a');
anchor.href = `#${elem.id}`;
anchor.classList.add('anchor-link');
anchor.title = "Link to this section";
anchor.innerText = '🔗';
elem.append(anchor);
});
});