@navfolio/friend-circle-sync 是独立的数据同步工具:它读取友链 JSON,使用每项的 rss 地址,或尝试 /rss.xml、/feed.xml、/atom.xml、/index.xml 等常用地址,最终写出标准文章数组。它不依赖 Astro,也可用于其他静态博客。
GitHub Actions 构建前同步
在部署工作流、bun run docs:build 之前加入:
- name: Sync friend circle uses: navfolio/friend-circle-sync@main with: input: ${{ vars.NAVFOLIO_FRIEND_LINKS_SRC }} output: public/friend-circle.json max-posts-per-feed: '12'文件只在 CI 工作目录中生成,随后被 Astro 原样复制到 dist/friend-circle.json。不要提交它到 Git;在本地想查看真实数据时,可手动运行:
git clone git@github.com:navfolio/friend-circle-sync.gitcd friend-circle-syncbun installbun run sync -- \ --input https://example.com/friendlinks.json \ --output ../your-site/public/friend-circle.json在 MDX 中展示
import FriendCircle from '@navfolio/mdx-components/FriendCircle.astro';
<FriendCircle feedSrc="/friend-circle.json" limit={10} />Friend circle
2 friends 5 active 5 posts
刷新按钮只会从构建好的文章池重新抽取,不会在访问页面时抓 RSS。卡片来源和字段说明请见 FriendLinkCard。
Comments
Quiet notes for this article.