diff --git a/public/main.ts b/public/main.ts index 7255cd1..d0e9e2b 100644 --- a/public/main.ts +++ b/public/main.ts @@ -6,26 +6,10 @@ import moment from 'moment'; import md from 'markdown-it'; import hljs from 'highlight.js'; + document.addEventListener('DOMContentLoaded', () => { - const themeMenu = document.getElementById('theme-menu')!; - const checkTheme = () => { - if (localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) { - document.documentElement.classList.add('dark') - } else { - document.documentElement.classList.remove('dark') - } - } - - checkTheme() - - window.matchMedia('(prefers-color-scheme: dark)') - .addEventListener('change',({ matches }) => { - checkTheme() - } - ) - document.getElementById('light-mode')!.onclick = (e) => { e.stopPropagation() localStorage.theme = 'light'; @@ -81,9 +65,10 @@ document.addEventListener('DOMContentLoaded', () => { if (lang && hljs.getLanguage(lang)) { try { return '
' +
-                            hljs.highlight(str, { language: lang, ignoreIllegals: true }).value +
+                            hljs.highlight(str, {language: lang, ignoreIllegals: true}).value +
                             '
'; - } catch (__) {} + } catch (__) { + } } return '
' + md().utils.escapeHtml(str) + '
'; diff --git a/templates/base/base_header.html b/templates/base/base_header.html index b0a67dc..39a62e3 100644 --- a/templates/base/base_header.html +++ b/templates/base/base_header.html @@ -3,6 +3,24 @@ +