feat: 添加 GitHub 统计数据展示功能

新增 GitHub 统计卡片和徽章组件,在项目卡片、详情页和侧边栏中展示 GitHub stars、forks 等统计数据

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-12-30 14:14:02 +08:00
co-authored by Claude
parent 443dc8370e
commit cae5686d2d
12 changed files with 1766 additions and 41 deletions
+21 -22
View File
@@ -1,5 +1,7 @@
import Link from 'next/link'
import { getTranslations } from 'next-intl/server'
import { GitHubTextStatsCard } from './GitHubTextStatsCard'
import { getGitHubInfoFromLinks } from '@/lib/github/badges'
interface ProjectSidebarProps {
project: {
@@ -37,6 +39,9 @@ export async function ProjectSidebar({ project, locale }: ProjectSidebarProps) {
const t = await getTranslations('project')
const displayName = locale === 'en' && project.nameEn ? project.nameEn : project.name
// 获取 GitHub 统计数据
const githubInfo = getGitHubInfoFromLinks(project.links)
return (
<aside className="space-y-8">
{/* Project Links Card */}
@@ -74,31 +79,25 @@ export async function ProjectSidebar({ project, locale }: ProjectSidebarProps) {
)
})}
</div>
{/* Stats Section */}
<div className="mt-8 pt-6 border-t border-gray-200 dark:border-gray-700">
<div className="grid grid-cols-2 gap-4">
<div>
<span className="text-xs text-gray-500 uppercase font-mono block mb-1">{t('license')}</span>
<span className="font-bold text-sm">MIT</span>
</div>
<div>
<span className="text-xs text-gray-500 uppercase font-mono block mb-1">{t('pricing')}</span>
<span className="font-bold text-sm">Free</span>
</div>
<div>
<span className="text-xs text-gray-500 uppercase font-mono block mb-1">{t('status')}</span>
<span className="font-bold text-sm">Active</span>
</div>
<div>
<span className="text-xs text-gray-500 uppercase font-mono block mb-1">{t('type')}</span>
<span className="font-bold text-sm">{t('openSource')}</span>
</div>
</div>
</div>
</div>
)}
{/* GitHub Statistics Card */}
{githubInfo.owner && githubInfo.repo && (
<GitHubTextStatsCard
stats={{
owner: githubInfo.owner,
repo: githubInfo.repo,
// 注意:目前使用徽章 URL,后续可以通过 API 获取实际文本数据
// 如需显示实际数字,需要使用 GitHub API 或服务端获取
stars: githubInfo.stars,
forks: githubInfo.forks,
issues: githubInfo.issues,
license: githubInfo.license
}}
/>
)}
{/* CTA Card */}
<div className="bg-primary border-2 border-black p-6 relative overflow-hidden shadow-brutal dark:shadow-none group cursor-pointer hover:bg-yellow-400 transition-colors">
<div className="absolute top-0 right-0 w-20 h-20 bg-white opacity-20 transform rotate-45 translate-x-10 -translate-y-10"></div>