--- export const prerender = true; import { LinkPresets } from "@constants/link-presets"; import { LinkPreset } from "@/types/config"; import { projectsData, getProjectStats, getProjectsByCategory, getFeaturedProjects, getAllTechStack, } from "@utils/projects"; import { UNCATEGORIZED } from "@constants/constants"; import { i18n } from "@i18n/translation"; import I18nKey from "@i18n/i18nKey"; import ProjectCard from "@components/data/projectCard.astro"; import GridLayout from "@layouts/grid.astro"; import BackwardButton from "@components/backwardButton.astro"; const title = LinkPresets[LinkPreset.Projects].name; const subtitle = LinkPresets[LinkPreset.Projects].description; // 获取项目统计信息 const stats = getProjectStats(); const featuredProjects = getFeaturedProjects(); const allTechStack = getAllTechStack(); // 获取所有分类 const categories = [ ...new Set(projectsData.map((project) => project.category)), ]; // 按分类获取项目 const projectsByCategory = categories.reduce( (acc, category) => { acc[category] = getProjectsByCategory(category); return acc; }, {} as Record, ); // 获取分类文本的国际化翻译 const getCategoryText = (category: string) => { switch (category) { case "actual": return i18n(I18nKey.projectsActual); case "history": return i18n(I18nKey.projectsHistory); case "other": return i18n(I18nKey.projectsOther); case UNCATEGORIZED: return i18n(I18nKey.uncategorized); default: return category; } }; ---

{i18n(I18nKey.projects)}

{i18n(I18nKey.projectsSubtitle)}

{stats.total}
{i18n(I18nKey.projectsTotal)}
{stats.byStatus.completed}
{i18n(I18nKey.projectsCompleted)}
{stats.byStatus.inProgress}
{i18n(I18nKey.projectsInProgress)}
{allTechStack.length}
{i18n(I18nKey.projectsTechStack)}
{featuredProjects.length > 0 && (

{i18n(I18nKey.projectsFeatured)}

{featuredProjects.map((project) => ( ))}
)}
{categories.map((category) => { const categoryProjects = projectsByCategory[category]; if (categoryProjects.length === 0) return null; return (

{getCategoryText(category)} ({categoryProjects.length})

{categoryProjects.map((project) => ( ))}
); })}

{i18n(I18nKey.projectsTechStack)}

{allTechStack.map((tech) => ( {tech} ))}