From 4cfc2585cdc0cf5fcadf1221293499f70e57b139 Mon Sep 17 00:00:00 2001 From: interlope Date: Tue, 2 Jun 2026 18:19:29 +0200 Subject: [PATCH] feat: implement random selection of sidebar navigation links on each load --- js/blowdit.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/js/blowdit.js b/js/blowdit.js index e41e614..3617937 100644 --- a/js/blowdit.js +++ b/js/blowdit.js @@ -153,9 +153,15 @@ })(); /* -------------------------------------------------------- - Randomise the order of the navigation / pages list on each load + Sidebar nav: show a random selection of links on each load. + The plugin renders the full list (set its "amount" high); we shuffle it + and reveal only SHOW_COUNT items — so it rotates through ALL articles + while keeping the sidebar short. All links stay in the DOM (good for + internal linking/crawl); the extras are just visually hidden. -------------------------------------------------------- */ (function () { + var SHOW_COUNT = 3; // how many random links to display; change to taste + function shuffle(arr) { for (var i = arr.length - 1; i > 0; i--) { var j = Math.floor(Math.random() * (i + 1)); @@ -168,7 +174,11 @@ var items = Array.prototype.filter.call(ul.children, function (el) { return el.tagName === 'LI'; }); - shuffle(items).forEach(function (li) { ul.appendChild(li); }); + shuffle(items); + items.forEach(function (li, i) { + ul.appendChild(li); // apply shuffled order + li.style.display = (i < SHOW_COUNT) ? '' : 'none'; // reveal only the first N + }); }); })();