feat(compatibility): improve compatibility for Hugo basic version (#352)

This commit is contained in:
Dillon
2020-05-13 00:45:19 +08:00
committed by GitHub
parent 6aa05a7f3e
commit 762a7e538d
26 changed files with 230 additions and 214 deletions

View File

@@ -27,9 +27,7 @@
{{- end -}}
{{- .Scratch.Set "params" $params -}}
{{- $this := dict "desktop" .Site.Params.header.desktopMode "mobile" .Site.Params.header.mobileMode | dict "headerMode" | dict "config" -}}
{{- .Scratch.Set "this" $this -}}
{{- .Scratch.Set "this" dict -}}
<!DOCTYPE html>
<html lang="{{ .Site.LanguageCode }}">
@@ -47,7 +45,7 @@
{{- partial "head/link.html" . -}}
{{- partial "head/seo.html" . -}}
</head>
<body>
<body header-desktop="{{ .Site.Params.header.desktopMode }}" 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>