diff --git a/assets/js/appearance.js b/assets/js/appearance.js
index 417b1a4a..c5ffafbe 100644
--- a/assets/js/appearance.js
+++ b/assets/js/appearance.js
@@ -1,8 +1,22 @@
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() {
+ var metaThemeColor = document.querySelector("meta[name=theme-color]");
+ document.documentElement.classList.contains("dark")
+ ? metaThemeColor.setAttribute("content", getCSSValue("--color-neutral-800"))
+ : metaThemeColor.setAttribute("content", getCSSValue("--color-neutral"));
+ return true;
+}
+
if ((sitePreference === "dark" && userPreference === null) || userPreference === "dark") {
document.documentElement.classList.add("dark");
+ setThemeColor();
}
if (document.documentElement.getAttribute("data-auto-appearance") === "true") {
@@ -12,6 +26,7 @@ if (document.documentElement.getAttribute("data-auto-appearance") === "true") {
userPreference !== "light"
) {
document.documentElement.classList.add("dark");
+ setThemeColor();
}
window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", (event) => {
if (event.matches) {
@@ -19,6 +34,7 @@ if (document.documentElement.getAttribute("data-auto-appearance") === "true") {
} else {
document.documentElement.classList.remove("dark");
}
+ setThemeColor();
});
}
@@ -27,6 +43,7 @@ window.addEventListener("DOMContentLoaded", (event) => {
if (switcher) {
switcher.addEventListener("click", () => {
document.documentElement.classList.toggle("dark");
+ setThemeColor();
localStorage.setItem(
"appearance",
document.documentElement.classList.contains("dark") ? "dark" : "light"
diff --git a/layouts/partials/head.html b/layouts/partials/head.html
index 22d24607..b38862b1 100644
--- a/layouts/partials/head.html
+++ b/layouts/partials/head.html
@@ -4,6 +4,7 @@
{{ end }}
+
{{/* Title */}}
{{ if .IsHome -}}