|
1 | 1 | <!DOCTYPE html> |
2 | | -<html lang="{{ page.lang | default: site.lang | default: 'zh-Hans' }}"> |
| 2 | +<html lang="{{ page.lang | default: site.lang | default: 'zh-Hans' }}" data-theme="light"> |
3 | 3 | <head> |
4 | 4 | <meta charset="utf-8"> |
5 | 5 | <meta http-equiv="X-UA-Compatible" content="IE=edge"> |
6 | 6 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
7 | | - |
8 | | - <!-- SEO 标签:自动生成 title, description, OG, Twitter Card, JSON-LD 等 --> |
| 7 | + |
9 | 8 | {% seo %} |
10 | | - |
11 | | - <!-- Canonical URL --> |
| 9 | + |
12 | 10 | <link rel="canonical" href="{{ page.url | absolute_url }}"> |
13 | | - |
14 | | - <!-- 站点级别的结构化数据 (Person Schema) --> |
| 11 | + |
15 | 12 | <script type="application/ld+json"> |
16 | 13 | { |
17 | 14 | "@context": "https://schema.org", |
|
25 | 22 | "description": "{{ site.description }}" |
26 | 23 | } |
27 | 24 | </script> |
28 | | - |
29 | | - <meta name="theme-color" content="#0f172a"> |
| 25 | + |
| 26 | + <meta name="theme-color" content="#f8fafc" media="(prefers-color-scheme: light)"> |
| 27 | + <meta name="theme-color" content="#0f172a" media="(prefers-color-scheme: dark)"> |
| 28 | + <meta name="theme-color" content="#f8fafc"> |
| 29 | + |
30 | 30 | <link rel="alternate" type="application/rss+xml" title="{{ site.title }}" href="{{ "/feed.xml" | absolute_url }}"> |
31 | 31 | <link rel="stylesheet" href="{{ "/assets/css/styles.css" | relative_url }}"> |
32 | | - |
33 | | - <!-- MathJax Configuration --> |
| 32 | + |
| 33 | + <script> |
| 34 | + (function () { |
| 35 | + var storageKey = 'pref-theme'; |
| 36 | + var root = document.documentElement; |
| 37 | + var storedTheme = localStorage.getItem(storageKey); |
| 38 | + if (storedTheme) { |
| 39 | + root.dataset.theme = storedTheme; |
| 40 | + return; |
| 41 | + } |
| 42 | + var prefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches; |
| 43 | + root.dataset.theme = prefersDark ? 'dark' : 'light'; |
| 44 | + })(); |
| 45 | + </script> |
| 46 | + |
| 47 | + {% if page.math or site.mathjax %} |
34 | 48 | <script> |
35 | 49 | MathJax = { |
36 | 50 | tex: { |
|
44 | 58 | } |
45 | 59 | }; |
46 | 60 | </script> |
47 | | - <script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js" id="MathJax-script" async></script> |
| 61 | + <script async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js" id="MathJax-script"></script> |
| 62 | + {% endif %} |
48 | 63 | </head> |
49 | 64 | <body class="layout-{{ page.layout | default: 'default' }}{% if page.body_class %} {{ page.body_class }}{% endif %}"> |
50 | 65 | <a class="skip-link" href="#main-content">跳至正文</a> |
|
60 | 75 | <li><a href="{{ "/archive/" | relative_url }}" {% if page.url == "/archive/" %}aria-current="page"{% endif %}>归档</a></li> |
61 | 76 | <li><a href="{{ "/about/" | relative_url }}" {% if page.url == "/about/" %}aria-current="page"{% endif %}>关于</a></li> |
62 | 77 | </ul> |
63 | | - <a class="nav-cta" href="{{ "/feed.xml" | relative_url }}">订阅 RSS</a> |
| 78 | + <div class="nav-actions"> |
| 79 | + <a class="nav-cta" href="{{ "/feed.xml" | relative_url }}">订阅 RSS</a> |
| 80 | + <button class="theme-toggle" type="button" aria-label="切换主题"> |
| 81 | + <svg class="theme-icon theme-icon-sun" viewBox="0 0 24 24" aria-hidden="true" focusable="false"> |
| 82 | + <path d="M12 4.75a.75.75 0 0 1-.75-.75V2.5a.75.75 0 1 1 1.5 0V4a.75.75 0 0 1-.75.75Zm6.364 2.136a.75.75 0 0 0 1.06-1.06l-1.06-1.06a.75.75 0 0 0-1.06 1.06l1.06 1.06ZM21.5 11.25H20a.75.75 0 0 0 0 1.5h1.5a.75.75 0 0 0 0-1.5ZM12 19.25a.75.75 0 0 0-.75.75V22a.75.75 0 0 0 1.5 0v-2a.75.75 0 0 0-.75-.75Zm-7.424-3.364-.03.03a.75.75 0 1 0 1.06 1.06l1.03-1.03a.75.75 0 0 0-1.06-1.06Zm1.03-9.546-1.03-1.03a.75.75 0 1 0-1.06 1.06l1.03 1.03a.75.75 0 1 0 1.06-1.06ZM4 12a.75.75 0 0 0-.75-.75H2.5a.75.75 0 0 0 0 1.5H3.25A.75.75 0 0 0 4 12Zm12.495 6.284 1.06 1.06a.75.75 0 0 0 1.06-1.06l-1.06-1.06a.75.75 0 0 0-1.06 1.06ZM12 7a5 5 0 1 1 0 10 5 5 0 0 1 0-10Z"></path> |
| 83 | + </svg> |
| 84 | + <svg class="theme-icon theme-icon-moon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"> |
| 85 | + <path d="M13.25 3.018a.75.75 0 0 1 .91-.91 9.25 9.25 0 1 1-10.232 10.23.75.75 0 0 1 .91-.91A7.75 7.75 0 1 0 13.25 3.018Z"></path> |
| 86 | + </svg> |
| 87 | + </button> |
| 88 | + </div> |
64 | 89 | </nav> |
65 | 90 | </div> |
66 | 91 | </header> |
|
0 commit comments