Repository navigation
Expand file tree
/
Copy patharticle-details.html
More file actions
406 lines (348 loc) · 15.2 KB
/
Copy patharticle-details.html
File metadata and controls
406 lines (348 loc) · 15.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
<!DOCTYPE html>
<html lang="zh-CN" class="dark">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>文章详情 | FingertipSpace</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="icon" href="untitled.svg" type="image/svg+xml">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Noto+Serif+SC:wght@300;400;600;700&display=swap" rel="stylesheet">
<!-- 引入微软雅黑字体 -->
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
<script>
tailwind.config = {
darkMode: 'class',
theme: {
extend: {
fontFamily: {
sans: ['Inter', '-apple-system', 'BlinkMacSystemFont', 'sans-serif'],
serif: ['"Noto Serif SC"', 'Georgia', 'serif'],
// ✅ 新增微软雅黑字体族
msyh: ['"Microsoft YaHei"', '"Noto Sans SC"', '"PingFang SC"', 'sans-serif'],
},
colors: {
paper: { bg: '#ffffff', surface: '#fafafa', text: '#1a1a1a', muted: '#6b7280', border: '#e5e7eb', hover: '#f3f4f6' },
ink: { bg: '#191919', surface: '#202020', text: '#e5e5e5', muted: '#9ca3af', border: '#2e2e2e', hover: '#2a2a2a' },
}
}
}
}
</script>
<style>
body {
background-color: #ffffff;
color: #1a1a1a;
transition: background-color 0.3s ease, color 0.3s ease;
}
.dark body {
background-color: #191919;
color: #e5e5e5;
}
.link-underline {
background-image: linear-gradient(currentColor, currentColor);
background-size: 0% 1px;
background-repeat: no-repeat;
background-position: 0% 100%;
transition: background-size 0.3s ease;
}
.link-underline:hover {
background-size: 100% 1px;
}
.page-transition {
animation: fadeIn 0.3s ease;
}
@keyframes fadeIn {
from {
opacity: 0;
transform: translateY(8px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
::-webkit-scrollbar {
width: 6px;
}
::-webkit-scrollbar-track {
background: transparent;
}
::-webkit-scrollbar-thumb {
background: #d1d5db;
border-radius: 3px;
}
.dark ::-webkit-scrollbar-thumb {
background: #4b5563;
}
/* ===== 文章内容样式 ===== */
.post-content {
font-family: 'Noto Serif SC', Georgia, serif;
font-size: 17px;
line-height: 1.8;
color: #1a1a1a;
}
.dark .post-content {
color: #e5e5e5;
}
.post-content h1 {
font-size: 2rem;
font-weight: 700;
margin: 1.5rem 0 0.8rem;
}
.post-content h2 {
font-size: 1.5rem;
font-weight: 600;
margin: 1.2rem 0 0.6rem;
}
.post-content h3 {
font-size: 1.25rem;
font-weight: 600;
margin: 1rem 0 0.4rem;
}
.post-content p {
margin: 0.8rem 0;
}
.post-content a {
color: #3fb950;
text-decoration: underline;
}
.post-content blockquote {
border-left: 4px solid #3fb950;
padding-left: 1rem;
margin: 1rem 0;
color: #6b7280;
}
.dark .post-content blockquote {
color: #9ca3af;
}
.post-content code {
background: #f3f4f6;
padding: 0.1rem 0.4rem;
border-radius: 4px;
font-size: 0.9em;
font-family: 'JetBrains Mono', monospace;
}
.dark .post-content code {
background: #2a2a2a;
}
.post-content pre {
background: #0d1117;
padding: 1rem;
border-radius: 8px;
overflow-x: auto;
margin: 1rem 0;
}
.post-content pre code {
background: transparent;
padding: 0;
}
.post-content img {
max-width: 100%;
border-radius: 8px;
margin: 1rem 0;
}
.post-content ul, .post-content ol {
padding-left: 1.5rem;
margin: 0.6rem 0;
}
/* ===== 文章标题样式(微软雅黑) ===== */
.article-title {
font-family: 'Microsoft YaHei', 'Noto Sans SC', 'PingFang SC', sans-serif;
font-weight: 300;
font-size: 2.25rem;
line-height: 1.3;
letter-spacing: 0.02em;
color: #1a1a1a;
margin-bottom: 0.5rem;
}
.dark .article-title {
color: #e5e5e5;
}
/* 文章元信息样式 */
.article-meta {
font-family: 'Inter', -apple-system, sans-serif;
font-size: 0.875rem;
color: #6b7280;
display: flex;
gap: 1rem;
flex-wrap: wrap;
padding-bottom: 1.5rem;
border-bottom: 1px solid #e5e7eb;
margin-bottom: 1.5rem;
}
.dark .article-meta {
color: #9ca3af;
border-bottom-color: #2e2e2e;
}
/* ===== 加载状态 ===== */
.loading-spinner {
border: 3px solid #e5e7eb;
border-top-color: #3fb950;
border-radius: 50%;
width: 40px;
height: 40px;
animation: spin 0.8s linear infinite;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
.hidden {
display: none;
}
</style>
</head>
<body>
<!-- ===== 顶部导航 ===== -->
<header class="sticky top-0 z-50 bg-white/80 dark:bg-ink-bg/80 backdrop-blur-md border-b border-paper-border dark:border-ink-border">
<div class="max-w-2xl mx-auto px-6 py-4 flex justify-between items-center">
<a href="#" onclick="navigateTo('home')" class="text-xl font-serif font-bold text-paper-text dark:text-ink-text hover:text-gray-500 transition cursor-pointer flex items-center gap-2">
<img src="untitled.svg" alt="FingertipSpace Icon" class="w-6 h-6 object-contain">
<span>FingertipSpace</span>
</a>
<nav class="flex items-center space-x-6 text-sm text-paper-muted dark:text-ink-muted font-medium">
<a href="/" class="link-underline hover:text-paper-text dark:hover:text-ink-text">首页</a>
<a href="../" class="link-underline hover:text-paper-text dark:hover:text-ink-text text-[#3fb950]">返回</a>
<button id="theme-toggle" class="p-1 hover:text-paper-text dark:hover:text-ink-text transition" title="切换主题">
<svg class="w-4 h-4 block dark:hidden" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z" /></svg>
<svg class="w-4 h-4 hidden dark:block" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z" /></svg>
</button>
</nav>
</div>
</header>
<!-- ===== 主体 ===== -->
<main class="max-w-2xl mx-auto px-6 py-12 page-transition">
<!-- ✅ 加载状态 -->
<div id="loading" class="flex flex-col items-center justify-center py-20">
<div class="loading-spinner"></div>
<p class="text-paper-muted dark:text-ink-muted mt-4 text-sm">文章加载中...</p>
</div>
<!-- ✅ 文章内容容器(包含标题和正文) -->
<div id="postContainer" class="hidden">
<!-- 文章标题(微软雅黑) -->
<h1 id="articleTitle" class="article-title">加载中...</h1>
<!-- 文章元信息(日期、标签) -->
<div id="articleMeta" class="article-meta">
<span id="articleDate"></span>
<span id="articleWriter"></span>
<span id="articleTags"></span>
</div>
<!-- 正文 -->
<div id="postContent" class="post-content"></div>
</div>
<!-- ✅ 错误状态 -->
<div id="errorContainer" class="hidden flex flex-col items-center justify-center py-20 text-center">
<h2 class="text-xl font-bold text-paper-text dark:text-ink-text">文章加载失败</h2>
<p id="errorMessage" class="text-paper-muted dark:text-ink-muted mt-2">请稍后重试</p>
<a href="/" class="mt-6 text-[#3fb950] hover:underline">← 返回首页</a>
</div>
</main>
<!-- ===== 页脚 ===== -->
<footer class="border-t border-paper-border dark:border-ink-border mt-12">
<div class="max-w-2xl mx-auto px-6 py-8 flex flex-col md:flex-row justify-between items-center text-xs text-paper-muted dark:text-ink-muted">
<p>© 2026 circlexhy. All rights reserved.</p>
</div>
</footer>
<script>
// ================================================================
// 1. 主题切换
// ================================================================
const themeToggle = document.getElementById('theme-toggle');
const htmlEl = document.documentElement;
if (localStorage.getItem('theme') === 'dark' ||
(!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
htmlEl.classList.add('dark');
}
themeToggle.addEventListener('click', () => {
htmlEl.classList.toggle('dark');
localStorage.setItem('theme', htmlEl.classList.contains('dark') ? 'dark' : 'light');
});
// ================================================================
// 2. 加载文章(从 JSON 获取标题,从 MD 获取正文)
// ================================================================
(async function loadPost() {
const params = new URLSearchParams(window.location.search);
const postName = params.get('postname');
const type = params.get('type'); // blogs 或 articles
const loading = document.getElementById('loading');
const postContainer = document.getElementById('postContainer');
const postContent = document.getElementById('postContent');
const errorContainer = document.getElementById('errorContainer');
const errorMessage = document.getElementById('errorMessage');
// 标题相关元素
const articleTitle = document.getElementById('articleTitle');
const articleDate = document.getElementById('articleDate');
const articleTags = document.getElementById('articleTags');
// 验证参数
if (!type || !postName) {
loading.classList.add('hidden');
errorContainer.classList.remove('hidden');
errorMessage.textContent = '缺少文章参数';
return;
}
try {
// ===== 第一步:获取 JSON 元数据 =====
const jsonUrl = `https://circlexhy.github.io/${type}/json/${postName}.json`;
const jsonResponse = await fetch(jsonUrl);
if (!jsonResponse.ok) {
if (jsonResponse.status === 404) {
throw new Error('文章元数据不存在');
}
throw new Error(`元数据加载失败 (${jsonResponse.status})`);
}
const jsonData = await jsonResponse.json();
const postMeta = jsonData.posts[0]; // 取第一条数据
if (!postMeta) {
throw new Error('文章元数据格式错误');
}
// ===== 第二步:获取 MD 正文 =====
const mdUrl = `https://circlexhy.github.io/${type}/posts/${postName}.md`;
const mdResponse = await fetch(mdUrl);
if (!mdResponse.ok) {
if (mdResponse.status === 404) {
throw new Error('文章正文不存在');
}
throw new Error(`正文加载失败 (${mdResponse.status})`);
}
const markdown = await mdResponse.text();
// ===== 第三步:渲染 =====
// 3.1 设置标题(微软雅黑)
articleTitle.textContent = postMeta.title || '无标题';
// 3.2 设置日期和标签
if (postMeta.date) {
articleDate.textContent = `${postMeta.date}`;
} else {
articleDate.textContent = '';
}
if (postMeta.writer) {
articleWriter.textContent = `@${postMeta.writer}`;
} else {
articleWriter.textContent = '@Unknown';
}
if (postMeta.tags && postMeta.tags.length > 0) {
articleTags.textContent = `${postMeta.tags.join(' · ')}`;
} else {
articleTags.textContent = '';
}
// 3.3 渲染正文
const htmlContent = marked.parse(markdown);
postContent.innerHTML = htmlContent;
// 3.4 更新页面标题
document.title = `${postMeta.title || postName} | FingertipSpace`;
// 3.5 显示文章,隐藏加载
loading.classList.add('hidden');
postContainer.classList.remove('hidden');
} catch (error) {
console.error('加载文章失败:', error);
loading.classList.add('hidden');
errorContainer.classList.remove('hidden');
errorMessage.textContent = error.message || '请稍后重试';
}
})();
</script>
</body>
</html>