fix(header): Use data attributes for header mode

Partially fixes: #401

Signed-off-by: Khusika Dhamar Gusti <mail@khusika.com>
This commit is contained in:
Khusika Dhamar Gusti
2020-11-26 06:52:07 +07:00
parent fbceb4ad5d
commit 1281b13109
9 changed files with 15 additions and 15 deletions

View File

@@ -14,7 +14,7 @@
{{- partial "head/link.html" . -}}
{{- partial "head/seo.html" . -}}
</head>
<body header-desktop="{{ .Site.Params.header.desktopMode }}" header-mobile="{{ .Site.Params.header.mobileMode }}">
<body data-header-desktop="{{ .Site.Params.header.desktopMode }}" data-header-mobile="{{ .Site.Params.header.mobileMode }}">
{{- /* Check theme isDark before body rendering */ -}}
{{- $theme := .Site.Params.defaulttheme -}}
<script type="text/javascript">(window.localStorage && localStorage.getItem('theme') ? localStorage.getItem('theme') === 'dark' : ('{{ $theme }}' === 'auto' ? window.matchMedia('(prefers-color-scheme: dark)').matches : '{{ $theme }}' === 'dark')) && document.body.setAttribute('theme', 'dark');</script>