feat: add data-subnav to garden pages
- Add _include/subnav.html SSI fragment (index | writing | now | status) - JS sets aria-current='page' by pathname prefix match - Applied to index, writings/index, both essays - Remove stale writing/ directory (canonical path is writings/) Closes vigilio/vault#11
This commit is contained in:
parent
a1449a08ef
commit
21ab566e1e
4 changed files with 18 additions and 121 deletions
18
_include/subnav.html
Normal file
18
_include/subnav.html
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<nav data-subnav aria-label="vigilio section">
|
||||
<a href="/vigilio/">index</a>
|
||||
<a href="/vigilio/writings/">writing</a>
|
||||
<a href="/vigilio/now/">now</a>
|
||||
<a href="/vigilio/status.html">status</a>
|
||||
</nav>
|
||||
<script>
|
||||
(function () {
|
||||
var path = location.pathname;
|
||||
document.querySelectorAll('[data-subnav] a').forEach(function (a) {
|
||||
var href = a.getAttribute('href');
|
||||
var exact = path === href;
|
||||
var prefix = href.endsWith('/') && path.startsWith(href);
|
||||
var file = !href.endsWith('/') && path === href;
|
||||
if (exact || prefix) a.setAttribute('aria-current', 'page');
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
Loading…
Add table
Add a link
Reference in a new issue