automatic theme based on browser theme

usage: add to config
    params:
        defaultTheme: "auto"
This commit is contained in:
Aditya Telange 2020-09-17 15:28:03 +05:30
parent 3081579764
commit 2eef3fcc12
No known key found for this signature in database
GPG Key ID: 82E844EF3DA99E77

View File

@ -1,3 +1,10 @@
{{ if eq .Site.Params.defaultTheme "auto" }}
<script>
if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
document.body.classList.add('dark');
}
</script>
{{ end }}
<header class="header"> <header class="header">
<nav class="nav"> <nav class="nav">
{{- if .IsHome }} {{- if .IsHome }}