feat: respect system theme for appearance

This commit is contained in:
Cory Dransfeldt 2023-07-02 22:00:04 -07:00
parent b45a643ce0
commit 91ad1fcdeb
No known key found for this signature in database
4 changed files with 2 additions and 35 deletions

View file

@ -53,14 +53,6 @@
href="/follow.xml"
title="Cory Dransfeldt's activity feed"
type="application/rss+xml">
<script>
const isDarkMode = () => localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches);
if (isDarkMode()) {
document.documentElement.classList.add('dark')
} else {
document.documentElement.classList.remove('dark')
}
</script>
<script type="application/ld+json">
{% jsonLd meta, type, tags %}
</script>
@ -69,15 +61,6 @@
<body class="dark:text-white bg-white dark:bg-gray-900 font-sans text-gray-800">
{{ content }}
<script>
document.getElementById("toggleDarkMode").addEventListener("click", function() {
if (isDarkMode()) {
localStorage.theme = 'light'
document.documentElement.classList.remove('dark')
} else {
localStorage.theme = 'dark'
document.documentElement.classList.add('dark')
}
});
(function() {
const pagination = document.getElementById('pagination');
if (pagination) {
@ -95,4 +78,4 @@
})()
</script>
</body>
</html>
</html>