Files
jiang13-forum/templates/base/head.tmpl
freefire 4a21d362d0 feat: 浅色/暗色主题并支持跟随系统
顶栏循环切换,localStorage 记忆;head 内联脚本避免首屏闪烁。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-30 04:54:15 +08:00

31 lines
1.2 KiB
Cheetah

{{define "base/head"}}
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>{{.Title}}</title>
{{if .Description}}<meta name="description" content="{{.Description}}"/>{{end}}
{{if .FaviconURL}}<link rel="icon" href="{{.FaviconURL}}"/>{{end}}
<meta property="og:title" content="{{.Title}}"/>
{{if .Description}}<meta property="og:description" content="{{.Description}}"/>{{end}}
{{if .OGImageURL}}<meta property="og:image" content="{{.OGImageURL}}"/>{{end}}
<script>
(function () {
try {
var key = "j13-theme";
var pref = localStorage.getItem(key) || "system";
if (pref !== "light" && pref !== "dark" && pref !== "system") pref = "system";
var dark = pref === "dark" || (pref === "system" && window.matchMedia("(prefers-color-scheme: dark)").matches);
var resolved = dark ? "dark" : "light";
document.documentElement.setAttribute("data-theme", resolved);
document.documentElement.setAttribute("data-theme-pref", pref);
document.documentElement.style.colorScheme = resolved;
} catch (e) {}
})();
</script>
<link rel="stylesheet" href="/ssr-assets/site.css"/>
</head>
<body class="j13-body">
{{end}}