Skip to content

Commit

Permalink
fix: only include themetoggle when needed (closes #98 )
Browse files Browse the repository at this point in the history
  • Loading branch information
not-matthias committed Feb 15, 2025
1 parent 25e9750 commit e3ff2f8
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions templates/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -147,23 +147,24 @@
{% endif %}

<!-- Set the correct theme in the script -->
<script src={{ get_url(path="js/themetoggle.js") }}></script>
{% if theme == "dark" %}
<script>setTheme("dark");</script>
{% elif theme == "light" %}
<script>setTheme("light");</script>
{% elif theme == "auto" %}
<script>
if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
setTheme("dark");
} else {
setTheme("light");
}
</script>
{% else %}
<script>setTheme(getSavedTheme());</script>

{% if theme == "auto" or theme == "toggle" %}
<script src={{ get_url(path="js/themetoggle.js") }}></script>

{% if theme == "auto" %}
<script>
if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
setTheme("dark");
} else {
setTheme("light");
}
</script>
{% else %}
<script>setTheme(getSavedTheme());</script>
{% endif %}
{% endif %}


<link rel="stylesheet" type="text/css" media="screen" href={{ get_url(path="main.css") }} />

{% if config.extra.stylesheets %}
Expand Down

0 comments on commit e3ff2f8

Please sign in to comment.