From 447ce2f52af9fd43858ed33f72f7384a491adcdc Mon Sep 17 00:00:00 2001
From: James Panther <4462786+jpanther@users.noreply.github.com>
Date: Tue, 22 Nov 2022 09:55:20 +1100
Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20Set=20`theme-color`=20using=20th?=
=?UTF-8?q?eme=20colour=20scheme?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
assets/js/appearance.js | 12 +++++++++---
layouts/partials/head.html | 2 +-
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/assets/js/appearance.js b/assets/js/appearance.js
index 322b7c7e..c5ffafbe 100644
--- a/assets/js/appearance.js
+++ b/assets/js/appearance.js
@@ -1,11 +1,17 @@
const sitePreference = document.documentElement.getAttribute("data-default-appearance");
const userPreference = localStorage.getItem("appearance");
+function getCSSValue(varName) {
+ var cssValue = window.getComputedStyle(document.documentElement).getPropertyValue(varName);
+ return "rgb(" + cssValue.replace(/\s+/g, "") + ")";
+}
+
function setThemeColor() {
- const metaThemeColor = document.querySelector("meta[name=theme-color]");
+ var metaThemeColor = document.querySelector("meta[name=theme-color]");
document.documentElement.classList.contains("dark")
- ? metaThemeColor.setAttribute("content", "#27272a")
- : metaThemeColor.setAttribute("content", "#ffffff");
+ ? metaThemeColor.setAttribute("content", getCSSValue("--color-neutral-800"))
+ : metaThemeColor.setAttribute("content", getCSSValue("--color-neutral"));
+ return true;
}
if ((sitePreference === "dark" && userPreference === null) || userPreference === "dark") {
diff --git a/layouts/partials/head.html b/layouts/partials/head.html
index 2de24263..b38862b1 100644
--- a/layouts/partials/head.html
+++ b/layouts/partials/head.html
@@ -4,7 +4,7 @@
{{ end }}
-
+
{{/* Title */}}
{{ if .IsHome -}}