🔧 Chore: inject a theme meta tag in the HTML head on the home page only

This commit is contained in:
Cell
2022-05-09 14:51:10 +08:00
parent adb8d5737e
commit 314fc909cd
4 changed files with 16 additions and 3 deletions
+6 -1
View File
@@ -484,7 +484,7 @@ enableEmoji = true
BuyMeaCoffee = ""
Linktree = ""
QQ = ""
QQGroup = ""
QQGroup = "814031017"
Diaspora = ""
CSDN = ""
Email = "xxxx@xxxx.com"
@@ -540,6 +540,11 @@ enableEmoji = true
# whether to add external Icon for external links automatically since v0.2.14
# 是否自动显示外链图标 since v0.2.14
externalIcon = true
# FixIt will, by default, inject a theme meta tag in the HTML head on the home page only. since v0.2.14
# You can turn it off, but we would really appreciate if you dont, as this is a good way to watch FixIt's popularity on the rise.
# 默认情况下,FixIt 只会在主页的 HTML 头中注入主题元标记。since v0.2.14
# 您可以将其关闭,但如果您不这样做,我们将不胜感激,因为这是观察 FixIt 受欢迎程度上升的好方法。
disableThemeInject = false
# Header config
# 页面头部导航栏配置
@@ -221,6 +221,9 @@ Please open the code block below to view the complete sample configuration :(far
enablePWA = true
# {{< version 0.2.14 >}} whether to add external Icon for external links automatically
externalIcon = false
# {{< version 0.2.14 >}} FixIt will, by default, inject a theme meta tag in the HTML head on the home page only.
# You can turn it off, but we would really appreciate if you dont, as this is a good way to watch FixIt's popularity on the rise.
disableThemeInject = false
# {{< version 0.2.0 >}} App icon config
[params.app]
@@ -223,6 +223,9 @@ hugo
enablePWA = true
# {{< version 0.2.14 >}} 是否自动显示外链图标
externalIcon = false
# {{< version 0.2.14 >}} 默认情况下,FixIt 只会在主页的 HTML 头中注入主题元标记。
# 您可以将其关闭,但如果您不这样做,我们将不胜感激,因为这是观察 FixIt 受欢迎程度上升的好方法。
disableThemeInject = false
# {{< version 0.2.0 >}} 应用图标配置
[params.app]
+4 -2
View File
@@ -3,8 +3,11 @@
<!DOCTYPE html>
<html lang="{{ .Site.LanguageCode }}">
<head>
{{ if (eq .Kind "home") | and (ne .Site.Params.disableThemeInject true) }}
<meta name="theme" content='FixIt {{ .Scratch.Get "version" }}'>
{{ end }}
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="robots" content="noodp" />
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
<title>
@@ -19,7 +22,6 @@
{{- /* 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>
{{- /* Body wrapper */ -}}
<div class="wrapper">
{{- partial "header.html" . -}}