diff --git a/src/components/GiteaActivity.astro b/src/components/GiteaActivity.astro index 2afda23..66d804a 100644 --- a/src/components/GiteaActivity.astro +++ b/src/components/GiteaActivity.astro @@ -1,39 +1,35 @@ --- -const heatmapLevels = [ - '#0f172a', - '#13233e', - '#1d4ed8', - '#2563eb', - '#22c55e', -]; +import type { GiteaActivityData } from '../data/loaders'; +import { site } from '../config'; -const heatmap = [ - 0, 1, 2, 0, 3, 1, 4, 2, 0, 1, - 1, 3, 0, 2, 1, 4, 2, 1, 0, 3, - 2, 0, 1, 3, 4, 1, 0, 2, 1, 3, - 0, 1, 4, 2, 0, 3, 1, 2, 4, 1, - 1, 2, 0, 3, 1, 4, 2, 0, 1, 2, - 0, 4, 1, 2, 3, 0, 2, 1, 4, 1, - 2, 1, 3, 0, 2, 1, 4, 2, 0, 1, -]; +interface Props { + activity: GiteaActivityData; +} -const recentActivities = [ - { - title: 'homepage landing', - detail: '重建首页骨架与模块层级', - time: '今天', - }, - { - title: 'design spec', - detail: '完成工程编辑部风格设计文档', - time: '今天', - }, - { - title: 'content seeds', - detail: '补齐示例日志、项目与分享数据', - time: '今天', - }, -]; +const { activity } = Astro.props; + +const heatmapLevels = ['#0f172a', '#13233e', '#1d4ed8', '#2563eb', '#22c55e']; +const heatmapSize = 70; +const heatmapCounts = activity.days.slice(-heatmapSize).map((day) => day.count); +const maxCount = Math.max(...heatmapCounts, 0); +const heatmap = Array.from({ length: heatmapSize }, (_, index) => { + const count = heatmapCounts[index] ?? 0; + + if (count <= 0 || maxCount <= 0) { + return 0; + } + + return Math.min( + heatmapLevels.length - 1, + Math.max(1, Math.ceil((count / maxCount) * (heatmapLevels.length - 1))), + ); +}); + +const recentActivities = activity.recent.slice(0, 3); +const updatedLabel = activity.updatedAt + ? new Date(activity.updatedAt).toLocaleString('zh-CN', { hour12: false }) + : '尚未同步'; +const isPlaceholder = activity.source === 'placeholder'; ---
@@ -41,17 +37,21 @@ const recentActivities = [
Gitea Activity

活跃度概览

-

首版先用静态面板承载未来的热力图与活动流位置,后续再接真实 API。

+

+ {isPlaceholder + ? '当前展示的是同步占位结果;接入 Gitea API 后,这里会显示真实热力图与最近活动。' + : '这里展示构建阶段同步下来的 Gitea 热力图与最近活动摘要。'} +

- + 打开 Gitea
-

贡献热力图区域预留给未来的客户端渲染模块。当前先用静态密度块确认布局节奏与深色模块层级。

-
+

最近同步:{updatedLabel}

+
{ heatmap.map((level) => ( { - recentActivities.map((item) => ( + recentActivities.length > 0 ? ( + recentActivities.map((item) => ( +
+ {item.repo} +

{item.message}

+

+ {item.time} +

+
+ )) + ) : (
- {item.title} -

{item.detail}

-

- {item.time} -

+ 暂无同步活动 +

先运行一次 content:sync,或等待后续接入真实 Gitea 数据源。

- )) + ) }
diff --git a/src/components/ProjectCard.astro b/src/components/ProjectCard.astro index 55adb4c..5fd3752 100644 --- a/src/components/ProjectCard.astro +++ b/src/components/ProjectCard.astro @@ -5,6 +5,7 @@ interface Props { coverImage: string; tags: string[]; repo: string; + repoUrl?: string; featured?: boolean; demoVideo?: string; downloadLink?: string; @@ -16,10 +17,14 @@ const { coverImage, tags, repo, + repoUrl, featured = false, demoVideo = '', downloadLink = '', } = Astro.props; + +const fallbackRepoUrl = repo ? `https://gitea.sepcomet.xyz/${repo}` : ''; +const resolvedRepoUrl = repoUrl || fallbackRepoUrl; ---
@@ -40,9 +45,11 @@ const {

Active repo

-

sepcomet/personal-homepage

+

{activeRepo}

Stack

@@ -106,6 +110,7 @@ const latestLog = latestLogs[0]; coverImage={project.cover_image} tags={project.tags} repo={project.gitea_repo} + repoUrl={project.repo_url} featured={project.featured} demoVideo={project.demo_video} downloadLink={project.download_link} @@ -118,7 +123,7 @@ const latestLog = latestLogs[0];
- +
diff --git a/src/pages/projects/index.astro b/src/pages/projects/index.astro index 1f10c2f..fb19d37 100644 --- a/src/pages/projects/index.astro +++ b/src/pages/projects/index.astro @@ -1,8 +1,10 @@ --- -import Layout from '../../layouts/Layout.astro'; import ProjectCard from '../../components/ProjectCard.astro'; import { site } from '../../config'; -import projects from '../../content/projects/index.json'; +import { loadProjects } from '../../data/loaders'; +import Layout from '../../layouts/Layout.astro'; + +const projects = await loadProjects(); --- Projects

项目展示

-

项目数据当前来自本地 JSON 文件,首页与此页面共享同一份结构化数据来源。

+

项目页现在优先读取构建阶段生成的数据;如果尚未同步,则回退到仓库里的种子数据。

@@ -27,6 +29,7 @@ import projects from '../../content/projects/index.json'; coverImage={project.cover_image} tags={project.tags} repo={project.gitea_repo} + repoUrl={project.repo_url} featured={project.featured} demoVideo={project.demo_video} downloadLink={project.download_link} diff --git a/src/pages/shares.astro b/src/pages/shares.astro index 3d552b8..386c84c 100644 --- a/src/pages/shares.astro +++ b/src/pages/shares.astro @@ -1,7 +1,9 @@ --- -import Layout from '../layouts/Layout.astro'; import { site } from '../config'; -import shares from '../content/shares/index.json'; +import { loadShares } from '../data/loaders'; +import Layout from '../layouts/Layout.astro'; + +const shares = await loadShares(); --- Shares

分享链接

-

这里预留给 Seafile 或其他公开资源的索引入口。当前先用静态数据确认列表版式。

+

这里优先展示构建时从 Seafile 同步生成的分享数据;当前未接入时会先回退到静态种子数据。