From 22c42bbd5f9f8a2c44b7bcf878a099393e2e7dfc Mon Sep 17 00:00:00 2001 From: Reijnn Date: Tue, 5 Mar 2019 13:16:59 +0100 Subject: [PATCH] theme-color now changes with site theme --- assets/js/theme.js | 4 +++ layouts/partials/favicons.html | 4 +-- layouts/partials/head.html | 49 +++++++++++++++++++--------------- 3 files changed, 34 insertions(+), 23 deletions(-) diff --git a/assets/js/theme.js b/assets/js/theme.js index d5a324b..37a59de 100644 --- a/assets/js/theme.js +++ b/assets/js/theme.js @@ -3,6 +3,7 @@ const getTheme = window.localStorage && window.localStorage.getItem("theme"); const themeToggle = document.querySelector(".theme-toggle"); const isDark = getTheme === "dark"; +var metaThemeColor = document.querySelector("meta[name=theme-color]"); if (getTheme !== null) { document.body.classList.toggle("dark-theme", isDark); @@ -15,4 +16,7 @@ themeToggle.addEventListener("click", () => { "theme", document.body.classList.contains("dark-theme") ? "dark" : "light", ); + document.body.classList.contains("dark-theme") ? + metaThemeColor.setAttribute("content", "#252627") : metaThemeColor.setAttribute("content", "#fafafa"); + ; }); diff --git a/layouts/partials/favicons.html b/layouts/partials/favicons.html index b454691..d3366ba 100644 --- a/layouts/partials/favicons.html +++ b/layouts/partials/favicons.html @@ -2,6 +2,6 @@ - + - \ No newline at end of file + \ No newline at end of file diff --git a/layouts/partials/head.html b/layouts/partials/head.html index bcab312..c7eae1f 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -1,31 +1,35 @@ - - - - - + + + + + {{ block "title" . }} - - {{ if .IsHome }} - {{ $.Site.Title }} {{ with $.Site.Params.Subtitle }} — {{ . }} {{ end }} - {{ else }} - {{ .Title }} :: {{ $.Site.Title }} {{ with $.Site.Params.Subtitle }} — {{ . }}{{ end }} - {{ end }} - + + {{ if .IsHome }} + {{ $.Site.Title }} {{ with $.Site.Params.Subtitle }} — {{ . }} {{ end }} + {{ else }} + {{ .Title }} :: {{ $.Site.Title }} {{ with $.Site.Params.Subtitle }} — {{ . }}{{ end }} + {{ end }} + {{ end }} - - + + {{ $style := resources.Get "scss/main.scss" | resources.ToCSS | resources.Minify | resources.Fingerprint }} {{- range .Site.Params.customCSS }} - + {{- end }} @@ -34,20 +38,23 @@ {{- template "_internal/schema.html" . }} {{- template "_internal/twitter_cards.html" . }} -{{ range .Params.categories }}{{ end }} -{{ if isset .Params "date" }}{{ end }} +{{ range .Params.categories }} +{{ end }} +{{ if isset .Params "date" }} +{{ end }} {{ if .RSSLink }} - + {{ end }} {{ if .OutputFormats.Get "json" }} - + {{ end }} {{- if templates.Exists "partials/extra-head.html" -}} - {{ partial "extra-head.html" . }} -{{- end }} +{{ partial "extra-head.html" . }} +{{- end }} \ No newline at end of file