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:
1 parent
945a9ee610
commit
4694428614
9 files changed
+449
-13
No files matched your search
@@ -2,6 +2,7 @@
|
||||
import type { CollectionEntry } from 'astro:content';
|
||||
import { getCollection, render } from 'astro:content';
|
||||
import BaseLayout from '../../layouts/BaseLayout.astro';
|
||||
import ArtalkComments from '../../components/ArtalkComments.astro';
|
||||
import { trackOf } from '../../content.config';
|
||||
|
||||
// URL = /archives/{slug},slug 即文件名,与 Halo 旧结构 1:1(不可改)
|
||||
@@ -104,8 +105,7 @@ const toc = headings.filter((h) => h.depth === 2 || h.depth === 3);
|
||||
)}
|
||||
</nav>
|
||||
|
||||
<!-- T8 填充:在此容器注入 Artalk 脚本,data-page-key 即文章 id -->
|
||||
<div id="artalk-container" data-page-key={entry.id}></div>
|
||||
<ArtalkComments pageKey={`/archives/${entry.id}/`} pageTitle={entry.data.title} />
|
||||
</BaseLayout>
|
||||
|
||||
<script>
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import rss from '@astrojs/rss';
|
||||
import { getCollection } from 'astro:content';
|
||||
import type { APIContext } from 'astro';
|
||||
|
||||
// RSS:posts 集合全量(draft 排除);Phase 3 起双语各出一路(/rss.xml 与 /en/rss.xml)
|
||||
export async function GET(context: APIContext) {
|
||||
const posts = (await getCollection('posts', ({ data }) => !data.draft))
|
||||
.sort((a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf());
|
||||
return rss({
|
||||
title: 'wait4x',
|
||||
description: '阅读 · 技术 · 摄影',
|
||||
site: context.site ?? 'https://wait4x.online',
|
||||
items: posts.map((p) => ({
|
||||
title: p.data.title,
|
||||
pubDate: p.data.pubDate,
|
||||
description: p.data.tags.join(', '),
|
||||
link: `/archives/${p.id}/`,
|
||||
})),
|
||||
trailingSlash: true,
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user