Sha256: 1fd01ea163c6bb6d1d719780a3d0a84865a9d533f0fa2b9f9ce5dc4e8c808d70
Contents?: true
Size: 888 Bytes
Versions: 3
Compression:
Stored size: 888 Bytes
Contents
// @ts-check import { qs, qsa } from './query.js'; /** * Sets the navigation based on the current page * * Example: You have a navigation tree with an "About" page with several child items. * When the user is on the "About" page, or any child pages, the navigation should * be automatically expanded so the user can orient themselves within the site. * * @param {string} className */ function setNavigationTree(className) { const site = document.location.origin; const location = document.location.pathname; qsa(className).forEach((summary) => { const anchorElement = /** @type {HTMLAnchorElement} */(qs('a', summary)); const address = anchorElement.href.replace(site, ''); if (location.startsWith(address)){ summary.setAttribute('open', 'open'); } }); } export { setNavigationTree };
Version data entries
3 entries across 3 versions & 1 rubygems