meta color added

This commit is contained in:
zzossig 2020-02-18 22:11:46 +09:00
parent 7e4098210d
commit f933e10cd3
2 changed files with 26 additions and 4 deletions

View File

@ -27,13 +27,13 @@
<meta property="twitter:description" content="{{ $.Param "description" }}">
{{ end }}
{{ hugo.Generator }}
<meta name="msapplication-TileColor" content="{{ $.Param "themecolor" | default "#ffffff" }}">
<meta name="msapplication-TileColor" content="{{ $.Scratch.Get "themeTitleColor" | default "#fff" }}">
<!-- Chrome, Firefox OS and Opera -->
<meta name="theme-color" content="{{ $.Param "themecolor" | default "#ffffff" }}">
<meta name="theme-color" content="{{ $.Scratch.Get "themeNavbarColor" | default "#fff" }}">
<!-- Windows Phone -->
<meta name="msapplication-navbutton-color" content="{{ $.Param "themecolor" | default "#ffffff" }}">
<meta name="msapplication-navbutton-color" content="{{ $.Scratch.Get "themeNavbarColor" | default "#fff" }}">
<!-- iOS Safari -->
<meta name="apple-mobile-web-app-status-bar-style" content="{{ $.Param "themecolor" | default "#ffffff" }}">
<meta name="apple-mobile-web-app-status-bar-style" content="{{ $.Scratch.Get "themeNavbarColor" | default "#fff" }}">
<link rel="canonical" href="{{ .Permalink | absLangURL }}">
<link rel="manifest" href="{{ "manifest.json" | relURL }}">
{{ if $.Site.Params.useFaviconGenerator }}

View File

@ -438,6 +438,25 @@
var selectThemeElem = document.querySelectorAll('.select-theme');
var selectThemeItemElem = document.querySelectorAll('.select-theme__item');
var setMetaColor = function(themeColor) {
if (themeColor.includes('dark')) {
{{ $.Scratch.Set "themeTitleColor" "#fcfcfa" }}
{{ $.Scratch.Set "themeNavbarColor" "#403E41" }}
} else if (themeColor.includes('light')) {
{{ $.Scratch.Set "themeTitleColor" "#555" }}
{{ $.Scratch.Set "themeNavbarColor" "#eee" }}
} else if (themeColor.includes('hacker')) {
{{ $.Scratch.Set "themeTitleColor" "#e3cd26" }}
{{ $.Scratch.Set "themeNavbarColor" "#252526" }}
} else if (themeColor.includes('solarized')) {
{{ $.Scratch.Set "themeTitleColor" "#586e75" }}
{{ $.Scratch.Set "themeNavbarColor" "#eee8d5" }}
} else if (themeColor.includes('kimbie')) {
{{ $.Scratch.Set "themeTitleColor" "#d3af86" }}
{{ $.Scratch.Set "themeNavbarColor" "#51412c" }}
}
}
if (localTheme) {
selectThemeItemElem ?
selectThemeItemElem.forEach(function (elem) {
@ -447,6 +466,9 @@
elem.classList.remove('is-active');
}
}) : null;
setMetaColor(localTheme);
} else {
setMetaColor(rootEleme.className);
}
selectThemeItemElem ?