mirror of
https://github.com/andwati/andwati.com.git
synced 2026-10-28 21:52:16 +00:00
redesign site as "case file" theme
- new paper/ink palette with single red accent, replacing catppuccin - self-hosted IBM Plex Serif (display) + Source Serif 4 (body), drop Outfit - rebuilt homepage masthead, numbered post index, navbar with active states - switch syntax highlighting + utterances to gruvbox, synced via postMessage - remove terminal/404 easter egg chrome, clean up remaining inline styles - fix stray syntax.css link causing a 404
This commit is contained in:
@@ -60,4 +60,29 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
});
|
||||
// Initial sync in case banner is already mounted
|
||||
setTimeout(syncCCTheme, 100);
|
||||
|
||||
// Sync Utterances (comments iframe) theme with the site theme.
|
||||
// The iframe only reads its initial `theme` attribute once, so later
|
||||
// changes must go through postMessage per the utterances protocol.
|
||||
const syncUtterancesTheme = () => {
|
||||
const commentsEl = document.getElementById('comments');
|
||||
const frame = document.querySelector('.utterances-frame');
|
||||
if (!commentsEl || !frame) return;
|
||||
const theme = htmlElement.classList.contains('dark')
|
||||
? commentsEl.dataset.utterancesThemeDark
|
||||
: commentsEl.dataset.utterancesThemeLight;
|
||||
frame.contentWindow.postMessage({ type: 'set-theme', theme }, 'https://utteranc.es');
|
||||
};
|
||||
new MutationObserver(syncUtterancesTheme).observe(htmlElement, {
|
||||
attributes: true,
|
||||
attributeFilter: ['class'],
|
||||
});
|
||||
// The iframe loads asynchronously, so poll briefly until it's mounted.
|
||||
let utterancesTries = 0;
|
||||
const utterancesPoll = setInterval(() => {
|
||||
if (document.querySelector('.utterances-frame') || ++utterancesTries > 20) {
|
||||
clearInterval(utterancesPoll);
|
||||
syncUtterancesTheme();
|
||||
}
|
||||
}, 250);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user