From f0d4e5f571017e0502835c5ec0abdf99b7ed7e8e Mon Sep 17 00:00:00 2001 From: syswave-dev <263179084+syswave-dev@users.noreply.github.com> Date: Tue, 5 May 2026 08:41:13 +0200 Subject: [PATCH] feat(pwa): persist frontmatter, comments, depth controls in localStorage Closes #20. Three new keys (pullmd-frontmatter, pullmd-comments, pullmd-comment-depth) follow the existing pullmd-lang/pullmd-theme pattern. Restored on load before updateDepthVisibility() so the depth label visibility reflects the persisted comments-toggle state. Bumps version to 2.1.0 and SW cache to v19. Co-Authored-By: Claude Opus 4.7 (1M context) --- CHANGELOG.md | 5 +++++ package.json | 2 +- public/index.html | 23 +++++++++++++++++++++++ public/sw.js | 2 +- 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 209e3b0..f1c3c5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## v2.1.0 — 2026-05-05 + +### Added +- PWA: persist frontmatter toggle, comments toggle and comment depth across reloads via `localStorage` (keys `pullmd-frontmatter`, `pullmd-comments`, `pullmd-comment-depth`). Closes #20. + ## v2.0.0 — 2026-XX-XX **Breaking:** PullMD now supports an authentication system. Existing installs keep working unchanged (default `PULLMD_AUTH_MODE=disabled`); operators who want auth must follow [`MIGRATION.md`](./MIGRATION.md). diff --git a/package.json b/package.json index 1eac5d3..586d626 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pullmd", - "version": "2.0.0", + "version": "2.1.0", "type": "module", "main": "server.js", "license": "AGPL-3.0-or-later", diff --git a/public/index.html b/public/index.html index 95c3c26..62056b1 100644 --- a/public/index.html +++ b/public/index.html @@ -1455,6 +1455,29 @@

Letzte Abrufe

} } + (function restorePwaControls() { + try { + var v = localStorage.getItem('pullmd-comments'); + if (v !== null) commentsToggle.checked = v === 'true'; + v = localStorage.getItem('pullmd-frontmatter'); + if (v !== null) frontmatterToggle.checked = v === 'true'; + v = localStorage.getItem('pullmd-comment-depth'); + if (v !== null) { + var n = parseInt(v, 10); + if (n >= 1 && n <= 10) depthInput.value = String(n); + } + } catch (e) {} + })(); + commentsToggle.addEventListener('change', function () { + try { localStorage.setItem('pullmd-comments', String(commentsToggle.checked)); } catch (e) {} + }); + frontmatterToggle.addEventListener('change', function () { + try { localStorage.setItem('pullmd-frontmatter', String(frontmatterToggle.checked)); } catch (e) {} + }); + depthInput.addEventListener('change', function () { + try { localStorage.setItem('pullmd-comment-depth', depthInput.value); } catch (e) {} + }); + function updateDepthVisibility() { depthLabel.style.display = commentsToggle.checked ? '' : 'none'; } diff --git a/public/sw.js b/public/sw.js index 256b414..45a7195 100644 --- a/public/sw.js +++ b/public/sw.js @@ -1,4 +1,4 @@ -const CACHE_NAME = 'pullmd-v18'; +const CACHE_NAME = 'pullmd-v19'; const SHELL_URLS = ['/', '/index.html', '/manifest.json']; self.addEventListener('install', (event) => {