diff --git a/www/public/js/params.js b/www/public/js/params.js index c466e18..01fbf1b 100644 --- a/www/public/js/params.js +++ b/www/public/js/params.js @@ -4,8 +4,7 @@ var just = p.get('just'); if (just && /^[a-z0-9-]+$/.test(just)) { document.documentElement.dataset.just = just; - var css = 'section[data-section]:not([data-section="' + just + '"]){display:none}' - + ' section[data-section="' + just + '"] .section-label{pointer-events:none;text-decoration:none;color:inherit}'; + var css = 'section[data-section]:not([data-section="' + just + '"]){display:none}'; document.head.appendChild(Object.assign(document.createElement('style'), { textContent: css })); } @@ -30,7 +29,10 @@ if (has) { document.documentElement.dataset.has = has; has = has.toLowerCase(); - document.addEventListener('DOMContentLoaded', function() { + } + + document.addEventListener('DOMContentLoaded', function() { + if (has) { document.querySelectorAll('section[data-section] .entry').forEach(function(entry) { if (entry.textContent.toLowerCase().indexOf(has) === -1) { entry.style.display = 'none'; @@ -41,6 +43,22 @@ entry.style.display = 'none'; } }); + } + + document.querySelectorAll('.section-label').forEach(function(a) { + var link = new URLSearchParams(a.search); + p.forEach(function(v, k) { if (!link.has(k)) link.set(k, v); }); + a.href = '?' + link.toString(); }); - } + + var find = document.getElementById('find'); + if (find) find.addEventListener('click', function(e) { + e.preventDefault(); + var term = prompt('find:'); + if (!term) return; + var q = new URLSearchParams(location.search); + q.set('has', term); + location.search = q.toString(); + }); + }); }(); diff --git a/www/src/layouts/Layout.astro b/www/src/layouts/Layout.astro index 5cea85d..ee442c2 100644 --- a/www/src/layouts/Layout.astro +++ b/www/src/layouts/Layout.astro @@ -28,7 +28,18 @@ const { title, description = 'personal website of ' + title, showHeader = true,
{showHeader && (