Skip to content

Commit

Permalink
Fix gh-88 (#96)
Browse files Browse the repository at this point in the history
* Fix gh-88

* Make darkreader-lock default to light mode

* Add comments and fix formatting for HtmlHead.svelte

---------

Co-authored-by: leah <[email protected]>
  • Loading branch information
RealFX-Code and leah authored Apr 1, 2024
1 parent 7ecec85 commit 2c9728d
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/lib/HtmlHead.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,37 @@
import prism_light from "prismjs/themes/prism.min.css?url";
import styles_dark from "quilt-bulma/dist/style-dark.min.css?url";
import styles_light from "quilt-bulma/dist/style-light.min.css?url";
import { onMount } from "svelte";
//
// userPrefersDarkMode is simple, It's true if the user has dark mode enabled in their browser.
//
let userPrefersDarkMode: boolean = false;
onMount(function () {
userPrefersDarkMode = window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches;
window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", (e) => {
userPrefersDarkMode = e.matches;
});
});
</script>

<svelte:head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />

{#if userPrefersDarkMode}
<!--
adding a darkreader-lock here makes the "darkreader"
extension realize that this is a dark mode site and
doesn't apply it's own dark mode above the one already
applied to this site.
see: https://github.com/darkreader/darkreader/blob/main/CONTRIBUTING.md#disabling-dark-reader-on-your-site
-->
<meta name="darkreader-lock" />
{/if}

<link rel="preconnect" href="https://quiltmc.org" />
<link rel="preconnect" href="https://fonts.bunny.net" />
<link rel="preconnect" href="https://kit.fontawesome.com" />
Expand Down

1 comment on commit 2c9728d

@Cozy-GitHub
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See preview on Cloudflare Pages: https://bc90d463.developer-wiki.pages.dev

Please sign in to comment.