1
0
mirror of https://github.com/cotes2020/jekyll-theme-chirpy.git synced 2026-06-22 07:48:42 +00:00

feat(theme): persist user theme preferences (#2756)

- Migrate theme persistence from `sessionStorage` to `localStorage`
- Rename theme HTML attribute to `data-bs-theme` for Bootstrap compatibility
- Trim and compile CSS according to the chosen theme mode
This commit is contained in:
Cotes Chung
2026-06-17 23:20:12 +08:00
committed by GitHub
parent ceb2a41463
commit 7496dd41fa
51 changed files with 541 additions and 153 deletions
+4 -4
View File
@@ -2,8 +2,8 @@
<script>
(function () {
const origin = 'https://utteranc.es';
const themeMapper = Theme.getThemeMapper('github-light', 'github-dark');
const initTheme = themeMapper[Theme.visualState];
const themeMap = Theme.newThemeMap('github-light', 'github-dark');
const initTheme = themeMap[Theme.resolvedTheme];
let script = document.createElement('script');
script.src = 'https://utteranc.es/client.js';
@@ -22,8 +22,8 @@
{%- comment -%}
Credit to <https://github.com/utterance/utterances/issues/170#issuecomment-594036347>
{%- endcomment -%}
if (event.source === window && event.data && event.data.id === Theme.ID) {
newTheme = themeMapper[Theme.visualState];
if (event.source === window && event.data && event.data.id === Theme.eventId) {
newTheme = themeMap[Theme.resolvedTheme];
const message = {
type: 'set-theme',