Skip to content

添加新 AI 项目流程说明

本文档介绍如何添加新的 AI 开源项目到网站。

快速开始

方式一:通过内容文件(推荐)

创建中英文内容文件,系统会自动生成 manifest 并同步到数据库。

# 1. 创建内容目录和文件
mkdir -p content/{zh,en}/ai/copilot-cli

# 2. 编辑中文内容
cat > content/zh/ai/copilot-cli/index.md << 'EOF'
---
title: "GitHub Copilot CLI"
github: "https://github.com/github/copilot-cli"
date: 2025-10-05T12:00:00Z
description: "GitHub 官方命令行 AI 助手"
tags:
  - OSS
  - CLI
categories:
  - Development Tools
---

GitHub Copilot CLI 是 GitHub 官方提供的命令行 AI 助手...
EOF

# 3. 编辑英文内容
cat > content/en/ai/copilot-cli/index.md << 'EOF'
---
title: "GitHub Copilot CLI"
github: "https://github.com/github/copilot-cli"
date: 2025-10-05T12:00:00Z
description: "Official GitHub CLI AI assistant"
tags:
  - OSS
  - CLI
categories:
  - Development Tools
---

GitHub Copilot CLI is an official command-line AI assistant...
EOF

# 4. 提交并推送
git add content/*/ai/copilot-cli/
git commit -m "feat: add GitHub Copilot CLI"
git push

完成! 等待 3-5 分钟:

  • ✅ Cloudflare Pages 自动部署
  • ✅ 自动生成 manifest
  • ✅ 自动检测并同步新项目到数据库
  • ✅ 网站即可访问

方式二:直接编辑 Manifest

如果只需要数据库记录,不需要内容页面:

# 1. 编辑 manifest
vim data/ai-projects-manifest.json

# 添加项目
{
  "repo": "github/copilot-cli",
  "name": "GitHub Copilot CLI",
  "slug": "copilot-cli",
  "description": "Official GitHub CLI AI assistant",
  "link": "https://copilot.github.com",
  "github": "https://github.com/github/copilot-cli",
  "tags": ["OSS", "CLI"],
  "categories": ["Development Tools"]
}

# 2. 提交推送
git add data/ai-projects-manifest.json
git commit -m "feat: add github/copilot-cli to manifest"
git push

完成! 部署会自动同步新项目到数据库。

Front Matter 配置

必需字段

---
title: "项目标题"                              # 必需
github: "https://github.com/owner/repo"      # 必需,完整 GitHub URL
date: 2025-10-05T12:00:00Z                   # 必需,发布日期
description: "项目简介"                        # 必需,用于 SEO
---

推荐字段

---
# 基本信息
slug: copilot-cli                            # URL slug(默认使用目录名)
oss_date: 2024-10-17T00:00:00Z             # 项目开源日期
author: GitHub                               # 作者/组织

# 分类
tags:
  - OSS
  - CLI
categories:
  - Development Tools

# 链接
link: "https://copilot.github.com"          # 官网
demo: ""                                     # 演示

# 展示
featured: false                              # 是否首页推荐
thumbnail: https://example.com/image.png    # 缩略图
---

字段说明

字段 类型 必需 说明
title string 项目标题
github string GitHub 仓库完整 URL
date datetime 内容发布日期(ISO 8601 格式)
description string 项目简介
slug string - URL slug,默认使用目录名
oss_date datetime - 项目开源日期
tags array - 标签数组
categories array - 分类数组
featured boolean - 是否首页推荐
thumbnail string - 缩略图 URL
link string - 官网链接
demo string - 演示链接
author string - 作者/组织

自动同步机制

工作流程

Git Push
    ↓
Cloudflare Pages 部署
    ↓
npm run build
    ├─ generate:ai-manifest (生成 manifest)
    ├─ hugo build (构建网站)
    └─ compress-json
    ↓
postbuild (自动触发)
    ↓
检查 manifest 变化
    ↓
┌─────────────────┐
│ Manifest 无变化  │ → 跳过同步(~0.5 秒)
└─────────────────┘
    ↓
┌─────────────────┐
│ 检测到新项目     │ → 自动同步新项目(~2-5 秒)
└─────────────────┘
    ↓
┌─────────────────┐
│ 仅元数据更新     │ → 跳过,等待 cron(~0.5 秒)
└─────────────────┘
    ↓
完成!

同步策略

场景 行为 耗时
Manifest 无变化 ✅ 跳过同步 ~0.5 秒
检测到新项目 ✅ 自动同步新项目 ~2-5 秒
仅元数据更新 ⏭️ 跳过,等待定时任务 ~0.5 秒

详见:同步指南

验证

检查 API

# 查询项目数据
curl "https://jimmysong.io/api/ai/projects/github/copilot-cli" | jq

# 期望输出
{
  "repo": "github/copilot-cli",
  "name": "GitHub Copilot CLI",
  "stars": 5420,
  "forks": 234,
  "commits": 1234,
  "contributors": 45,
  "healthScore": 85.5,
  "updatedAt": "2025-10-05T10:30:00Z"
}

访问页面

# 打开项目页面
open "https://jimmysong.io/ai/copilot-cli/"

# 检查项目列表
open "https://jimmysong.io/ai/"

查看日志

Cloudflare Pages 部署日志

搜索 "Post-Deploy Sync" 查看同步结果:

🔍 Checking AI projects manifest changes...
✨ Manifest changes detected, checking for new projects...

🎯 Found 1 new project(s):
   • github/copilot-cli

🔄 Syncing new projects...
   ✅ github/copilot-cli synced successfully

✅ Successfully synced 1 new project(s)
✓ Post-deploy sync completed

Worker 日志

npx wrangler tail ai-oss-rank-worker

手动同步(可选)

如果自动同步失败或需要立即验证:

# 同步特定项目
npm run sync:repo github/copilot-cli

# 或使用脚本
bash scripts/trigger-worker-sync.sh --repo github/copilot-cli

详见:同步指南 - 手动同步

批量添加

# 1. 创建多个项目目录
for repo in copilot-cli project-a project-b; do
  mkdir -p content/{zh,en}/ai/$repo
  # 编辑内容文件...
done

# 2. 生成 manifest(可选,build 会自动执行)
npm run generate:ai-manifest

# 3. 验证
jq '.projectCount' static/data/ai-projects-manifest.json

# 4. 提交推送
git add content/*/ai/ static/data/
git commit -m "feat: add multiple AI projects"
git push

# 自动同步会处理所有新项目

常见问题

Q: 新项目多久能看到?

自动同步:3-5 分钟(推送 → 部署 → 自动同步)

手动同步:2 秒(npm run sync:repo owner/project

Q: 为什么同步被跳过?

Manifest 无变化时会跳过同步,这是正常的:

ℹ️  No changes in AI projects manifest, skipping sync
   Daily cron job at 00:00 UTC handles routine synchronization

只有添加新项目时才会触发同步。

Q: 健康指标没显示?

检查步骤:

  1. 确认同步成功

    curl "https://jimmysong.io/api/ai/projects/owner/project" | jq
    
  2. 查看浏览器控制台:检查 JavaScript 错误

  3. 手动触发同步

    npm run sync:repo owner/project
    

Q: 如何更新项目信息?

元数据更新(如标签、分类):

  • 修改内容文件 → Git push → 等待每日 cron(00:00 UTC)
  • 或手动同步:npm run sync:repo owner/project

GitHub 指标更新

  • 每日 cron 自动更新所有项目
  • 或手动同步:npm run sync:repo owner/project

相关文档

总结

添加新 AI 项目的最简流程:

# 1. 创建内容文件
mkdir -p content/{zh,en}/ai/project-name
# 编辑内容...

# 2. 提交推送
git add content/*/ai/project-name/
git commit -m "feat: add AI project"
git push

# 3. 完成!
# ✅ 3-5 分钟后自动部署并同步

一切都是自动的:

  • ✅ Manifest 自动生成
  • ✅ 新项目自动检测
  • ✅ 数据库自动同步
  • ✅ 健康指标自动显示

无需记住复杂命令!🎉