feat(search): 站内搜索/RSS/sitemap/Artalk 懒挂载

- astro-pagefind:构建期索引;SearchDialog 首开懒加载 + 200ms 防抖,
  入口=Header 钮 + 键盘 /(P0 键位集补全)
- @astrojs/rss:posts 全量(draft 排除),双语分流留 Phase 3
- @astrojs/sitemap:sitemap-index 产出
- ArtalkComments:IntersectionObserver 进入视口才拉 Artalk.js,
  pageKey=/archives/{slug}/(中英共键,评论不分裂)

验证: pnpm astro build exit 0;dist/pagefind 目录 + rss.xml +
      sitemap-index.xml 三件断言过

Spec: 2026-10-24_add-blog-skeleton
Co-authored-by: GLM-5.3
This commit is contained in:
wait4xandGLM-5.3 committed 2026-10-25 00:13:29 +08:00
1 parent 945a9ee610
commit 4694428614
9 files changed
+449 -13

No files matched your search

+43
View File
@@ -0,0 +1,43 @@
---
// Artalk 评论挂载(Phase 0 已部署 @ https://wait4x.online/artalk)
// 懒加载:进入视口才拉 Artalk.js,长文页不为其付首屏成本
interface Props {
pageKey: string; // 评论流键:中英双语页共用同一 slug(评论不分裂)
pageTitle: string;
}
const { pageKey, pageTitle } = Astro.props;
---
<div id="artalk-container" data-page-key={pageKey} data-page-title={pageTitle}></div>
<script>
const el = document.getElementById('artalk-container');
if (el) {
const mount = () => {
if (document.getElementById('artalk-lib')) return initArtalk();
const s = document.createElement('script');
s.id = 'artalk-lib';
s.src = 'https://wait4x.online/artalk/dist/Artalk.js';
s.onload = initArtalk;
document.head.appendChild(s);
};
const initArtalk = () => {
const lib = (window as unknown as { Artalk?: { init: (o: object) => void } }).Artalk;
lib?.init({
el: '#artalk-container',
server: 'https://wait4x.online/artalk',
site: 'wait4x',
pageKey: el.dataset.pageKey,
pageTitle: el.dataset.pageTitle,
locale: 'zh-CN',
});
};
// 进入视口 ~200px 前挂载;无 IO 环境直接挂
if ('IntersectionObserver' in window) {
new IntersectionObserver(
(entries, obs) => { if (entries.some((e) => e.isIntersecting)) { obs.disconnect(); mount(); } },
{ rootMargin: '200px' }
).observe(el);
} else mount();
}
</script>