docs(pages): 将 Giscus 评论插件添加到博客

2. fix(config): 修复特殊日期判断失败的问题
3. feat(giscus): 加入 Giscus 评论系统
This commit is contained in:
Ad-closeNN
2025-08-17 12:09:39 +08:00
parent 359d428204
commit 4690ce39b2
17 changed files with 395 additions and 73 deletions
+11 -11
View File
@@ -71,9 +71,6 @@ const bannerOffsetByPosition = {
const bannerOffset =
bannerOffsetByPosition[siteConfig.banner.position || "center"];
// 周日判断
const isSunday = new Date().getDay() === 0;
---
<!DOCTYPE html>
@@ -102,14 +99,10 @@ const isSunday = new Date().getDay() === 0;
<meta property="twitter:url" content={Astro.url}>
<meta name="twitter:title" content={pageTitle}>
<meta name="twitter:description" content={description || pageTitle}>
<meta id="theme-color-meta" name="theme-color" content="#48823b" />
{ isSunday &&
<meta name="theme-color" content="#9e8eef" />
}
{ !isSunday &&
<meta name="theme-color" content="#48823b" />
}
<meta name="viewport" content="width=device-width" />
<meta name="generator" content={Astro.generator} />
{favicons.map(favicon => (
@@ -145,6 +138,13 @@ const isSunday = new Date().getDay() === 0;
//const hue = localStorage.getItem('hue') || configHue;
document.documentElement.style.setProperty('--hue', hue);
// 设置主题色(新增这部分)
const themeColor = currentDay === 0 ? '#9e8eef' : '#48823b';
const metaThemeColor = document.getElementById('theme-color-meta');
if (metaThemeColor) {
metaThemeColor.setAttribute('content', themeColor);
}
// calculate the --banner-height-extend, which needs to be a multiple of 4 to avoid blurry text
let offset = Math.floor(window.innerHeight * (BANNER_HEIGHT_EXTEND / 100));
offset = offset - offset % 4;
@@ -622,4 +622,4 @@ if (window.swup) {
} else {
document.addEventListener("swup:enable", setup)
}
</script>
</script>