refactor: 统一API鉴权并提升代码健壮性
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import Link from 'next/link'
|
||||
import Image from 'next/image'
|
||||
import { GitHubStatsCompact } from './GitHubBadges'
|
||||
import { getGitHubBadgesFromLinks } from '@/lib/github/badges'
|
||||
|
||||
interface ProjectCardProps {
|
||||
@@ -53,7 +52,7 @@ export function ProjectCard({ project, locale, featured = false, translations }:
|
||||
const displayDescription = locale === 'en' && project.descriptionEn ? project.descriptionEn : project.description
|
||||
|
||||
// Generate GitHub badge URLs
|
||||
const badges = project.links ? getGitHubBadgesFromLinks(project.links as any) : { stars: null, forks: null }
|
||||
const badges = project.links ? getGitHubBadgesFromLinks(project.links) : { stars: null }
|
||||
|
||||
// Helper to get display name for tag based on locale
|
||||
const getTagName = (tag: { name: string; nameEn?: string | null }) => {
|
||||
@@ -105,7 +104,7 @@ export function ProjectCard({ project, locale, featured = false, translations }:
|
||||
{/* GitHub Stars Badge */}
|
||||
{badges.stars && (
|
||||
<div className="flex items-center gap-1 text-sm text-gray-600 dark:text-gray-400">
|
||||
<svg className="w-4 h-4" fill="currentColor" viewBox="0 0 16 16">
|
||||
<svg className="w-4 h-4" fill="currentColor" viewBox="0 0 16 16" aria-hidden="true">
|
||||
<path d="M8 .25a.75.75 0 01.673.418l1.882 3.815 4.21.612a.75.75 0 01.416 1.279l-3.046 2.97.719 4.192a.75.75 0 01-1.088.791L8 12.347l-3.766 1.98a.75.75 0 01-1.088-.79l.72-4.194L.818 6.374a.75.75 0 01.416-1.28l4.21-.611L7.327.668A.75.75 0 018 .25z"/>
|
||||
</svg>
|
||||
<Image
|
||||
@@ -115,6 +114,7 @@ export function ProjectCard({ project, locale, featured = false, translations }:
|
||||
height={20}
|
||||
unoptimized
|
||||
className="rounded"
|
||||
style={{ width: '70px', height: '20px' }}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user