(function () { // Remembers which sidebar
sections (one per tag, plus // "Untagged" — see templates/core/_sidebar.html's data-sidebar-key) // the user has collapsed, so a full page navigation (this isn't an // SPA — every click re-renders the sidebar server-side) doesn't keep // snapping them back open. Per-browser via localStorage, same pattern // as theme.js/theme-init.js — not synced across devices/accounts. var STORAGE_KEY = "evection-sidebar-collapsed"; function readCollapsed() { try { var raw = localStorage.getItem(STORAGE_KEY); return raw ? JSON.parse(raw) : []; } catch (e) { return []; } } function writeCollapsed(keys) { try { localStorage.setItem(STORAGE_KEY, JSON.stringify(keys)); } catch (e) { /* localStorage unavailable (private mode, etc.) — state just won't persist */ } } var collapsed = readCollapsed(); document.querySelectorAll(".sidebar-section[data-sidebar-key]").forEach(function (details) { var key = details.dataset.sidebarKey; if (collapsed.indexOf(key) !== -1) { details.open = false; } details.addEventListener("toggle", function () { var current = readCollapsed(); var index = current.indexOf(key); if (details.open) { if (index !== -1) current.splice(index, 1); } else if (index === -1) { current.push(key); } writeCollapsed(current); }); }); })();