diff --git a/index.ts b/index.ts index 9d6b2a8..024c4c6 100644 --- a/index.ts +++ b/index.ts @@ -29,10 +29,17 @@ interface RFC { git: RFCGitInfo; } +const HLJS_VERSION = "11.11.1"; +const HLJS_CDN = `https://cdnjs.cloudflare.com/ajax/libs/highlight.js/${HLJS_VERSION}`; + const THEME_SCRIPT = ` (function() { const saved = localStorage.getItem('theme') || 'light'; document.documentElement.setAttribute('data-theme', saved); + var light = document.getElementById('hljs-light'); + var dark = document.getElementById('hljs-dark'); + if (light) light.disabled = saved === 'dark'; + if (dark) dark.disabled = saved !== 'dark'; })(); `; @@ -60,6 +67,10 @@ function updateToggleIcon() { const current = document.documentElement.getAttribute('data-theme'); btn.innerHTML = current === 'dark' ? '${ICON_SUN}' : '${ICON_MOON}'; btn.setAttribute('aria-label', current === 'dark' ? 'Switch to light mode' : 'Switch to dark mode'); + var light = document.getElementById('hljs-light'); + var dark = document.getElementById('hljs-dark'); + if (light) light.disabled = current === 'dark'; + if (dark) dark.disabled = current !== 'dark'; } document.addEventListener('DOMContentLoaded', updateToggleIcon); @@ -93,6 +104,8 @@ function baseHTML(