Skip to content

Commit 880b2cf

Browse files
committed
Merge branch 'feat/contributor'
2 parents e4f59e0 + 4e7c43d commit 880b2cf

File tree

88 files changed

+4851
-332
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+4851
-332
lines changed

.github/workflows/sync-uuid.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Docs Backfill (on docs changes)
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- feat/contributor
8+
paths:
9+
- "app/docs/**"
10+
- "scripts/uuid.mjs"
11+
- "scripts/backfill-contributors.mjs"
12+
- "package.json"
13+
- "pnpm-lock.yaml"
14+
- ".github/workflows/sync-uuid.yml"
15+
- "generated/doc-contributors.json"
16+
workflow_dispatch: {}
17+
18+
concurrency:
19+
group: backfill-${{ github.ref }}
20+
cancel-in-progress: true
21+
22+
jobs:
23+
backfill:
24+
# 防止 fork、限定 main、并避免机器人循环
25+
if: github.repository == 'InvolutionHell/involutionhell.github.io' &&
26+
(github.ref == 'refs/heads/main' || github.ref == 'refs/heads/feat/contributor') &&
27+
github.actor != 'github-actions[bot]'
28+
runs-on: ubuntu-latest
29+
permissions:
30+
contents: write
31+
env:
32+
DATABASE_URL: ${{ secrets.DATABASE_URL }}
33+
GITHUB_TOKEN: ${{ secrets.GH_PAT }} # 供脚本调用 GitHub API 提升速率
34+
DOCS_DIR: app/docs
35+
36+
steps:
37+
- uses: actions/checkout@v4
38+
39+
- uses: pnpm/action-setup@v4
40+
with:
41+
version: 9
42+
43+
- uses: actions/setup-node@v4
44+
with:
45+
node-version: 20
46+
cache: "pnpm" # 顺便启用 pnpm 缓存,加速
47+
48+
- name: Install deps
49+
run: pnpm install --frozen-lockfile
50+
51+
- name: Generate Prisma Client
52+
run: pnpm prisma generate
53+
54+
- name: Ensure docId frontmatter
55+
run: pnpm exec node scripts/uuid.mjs
56+
57+
- name: Backfill contributors & sync DB
58+
run: pnpm exec node scripts/backfill-contributors.mjs
59+
60+
- name: Auto-commit doc metadata (if any)
61+
uses: stefanzweifel/git-auto-commit-action@v5
62+
with:
63+
commit_message: "chore(docs): sync doc metadata [skip ci]" # ← 防循环
64+
file_pattern: "app/docs/**/*.md app/docs/**/*.mdx generated/doc-contributors.json"
65+
66+
- name: Upload snapshot JSON
67+
uses: actions/upload-artifact@v4
68+
with:
69+
name: doc-contributors-snapshot
70+
path: generated/doc-contributors.json
71+
if-no-files-found: ignore

app/components/Contributors.tsx

Lines changed: 60 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
import Image from "next/image";
22
import Link from "next/link";
3+
import type { DocContributorsRecord } from "@/lib/contributors";
34

4-
interface Contributor {
5-
login: string;
6-
avatar_url: string;
7-
html_url: string;
5+
interface ContributorsProps {
6+
entry: DocContributorsRecord | null;
87
}
98

10-
export function Contributors({
11-
contributors,
12-
}: {
13-
contributors: Contributor[];
14-
}) {
9+
function formatLastContributedAt(value: string | null) {
10+
if (!value) return null;
11+
const date = new Date(value);
12+
if (Number.isNaN(date.getTime())) return null;
13+
return new Intl.DateTimeFormat("zh-CN", {
14+
year: "numeric",
15+
month: "2-digit",
16+
day: "2-digit",
17+
}).format(date);
18+
}
19+
20+
export function Contributors({ entry }: ContributorsProps) {
21+
const contributors = entry?.contributors ?? [];
22+
1523
if (contributors.length === 0) {
1624
return null;
1725
}
@@ -21,25 +29,54 @@ export function Contributors({
2129
<hr className="border-border/70 !mt-10 !mb-5" />
2230
<h2 id="contributors-heading">贡献者</h2>
2331
<ul className="mt-0 mb-0 flex flex-wrap items-center gap-x-6 gap-y-4 list-none p-0">
24-
{contributors.map((contributor) => (
25-
<li key={contributor.login}>
26-
<Link
27-
href={contributor.html_url}
28-
target="_blank"
29-
rel="noopener noreferrer"
30-
className="inline-flex items-center gap-3 text-base font-medium text-primary transition-colors hover:text-primary/80 no-underline"
31-
>
32+
{contributors.map((contributor) => {
33+
const displayName = contributor.login ?? `#${contributor.githubId}`;
34+
const href = contributor.htmlUrl ?? undefined;
35+
const avatarSrc =
36+
contributor.avatarUrl ??
37+
`https://avatars.githubusercontent.com/u/${contributor.githubId}`;
38+
const lastDate = formatLastContributedAt(
39+
contributor.lastContributedAt,
40+
);
41+
42+
const content = (
43+
<>
3244
<Image
33-
src={contributor.avatar_url}
34-
alt={contributor.login}
45+
src={avatarSrc}
46+
alt={displayName}
3547
width={35}
3648
height={35}
3749
className="!m-0 h-10 w-10 rounded-full border border-border/50 object-cover shadow-sm"
3850
/>
39-
<span>{contributor.login}</span>
40-
</Link>
41-
</li>
42-
))}
51+
<span className="flex flex-col text-left leading-tight">
52+
<span className="font-medium">{displayName}</span>
53+
<span className="text-sm text-muted-foreground">
54+
贡献 {contributor.contributions}
55+
{lastDate ? ` · 最近 ${lastDate}` : ""}
56+
</span>
57+
</span>
58+
</>
59+
);
60+
61+
return (
62+
<li key={contributor.githubId}>
63+
{href ? (
64+
<Link
65+
href={href}
66+
target="_blank"
67+
rel="noopener noreferrer"
68+
className="inline-flex items-center gap-3 text-base text-primary transition-colors hover:text-primary/80 no-underline"
69+
>
70+
{content}
71+
</Link>
72+
) : (
73+
<div className="inline-flex items-center gap-3 text-base">
74+
{content}
75+
</div>
76+
)}
77+
</li>
78+
);
79+
})}
4380
</ul>
4481
<hr className="!mb-0 !mt-5 border-border/70" />
4582
</section>

app/docs/CommunityShare/Geek/CommonUsedMarkdown.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: 常用Markdown语法
3-
date: 2025-09-20 14:25:39
3+
date: 2025-09-20T14:25:39.000Z
4+
docId: xqz5iiv3p52h6d9g3c0w2baf
45
---
56

67
## 基础标题+字体样式

app/docs/CommunityShare/Geek/Katex/Seb1.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: 个人常用字符
3-
date: 2025-09-20 14:25:39
3+
date: 2025-09-20T14:25:39.000Z
4+
docId: r0inttjcby48tly602p410vo
45
---
56

67
## 希腊字母

app/docs/CommunityShare/Geek/Katex/Seb2.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: 数学公式语法
3-
date: 2025-09-20 14:25:39
3+
date: 2025-09-20T14:25:39.000Z
4+
docId: khcrztruqdku9fntd3dwzvwe
45
---
56

67
## 求和、求积、二项式

app/docs/CommunityShare/Geek/Katex/index.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: 常用Katex语法
3-
date: 2025-09-20 14:25:39
3+
date: 2025-09-20T14:25:39.000Z
4+
docId: yxd2qpfl2li6092bjx8bz7vb
45
---
56

67
Katex 与 Latex 有些许的不同,稍作整理以便自己查阅

app/docs/CommunityShare/Geek/git101.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
---
2-
title: "Git入门操作指南-程序员必会的git小技巧"
2+
title: Git入门操作指南-程序员必会的git小技巧
33
description: ""
44
date: "2025-09-19"
55
tags:
66
- tag-one
7+
docId: tksz80mfqqyzwzzer5p3uxtg
78
---
89

910
## GIT 最常用命令
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
2-
title: "技术分享"
2+
title: 技术分享
33
date: "2025-09-18"
4+
docId: jee9yt8n8tmo8yclqujerw2x
45
---
56

67
欢迎来到技术分享板块!

app/docs/CommunityShare/Geek/raspberry-guide.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
---
22
title: 用闲置树莓派搭建一个Minecraft服务器
3-
date: 2025-08-05 18:53:40
4-
tags:
3+
date: 2025-08-05T18:53:40.000Z
4+
tags: null
5+
docId: i0xmpskau105p83vq35wnxls
56
---
67

78
记录一下从0开始搭建一个树莓派minecraft服务器,并且使用FRP内网穿透到公网

app/docs/CommunityShare/Geek/swanlab.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
---
2-
title: 'swanlab快速上手指南'
2+
title: swanlab快速上手指南
33
description: ""
44
date: "2025-09-23"
55
tags:
66
- tag-one
7+
docId: mhyoknm6vj8jmp186oli5f5c
78
---
89

910
最近在做实验,发现实验次数多了之后特别容易乱,而且实验结果也很难记录,甚至我都准备用最麻烦的excel来记录。
@@ -14,7 +15,7 @@ tags:
1415
## 1. 注册账号 & 获取 API Key
1516

1617
首先打开 SwanLab 官网:[https://swanlab.cn/](https://swanlab.cn/)
17-
如果还没有账号,需要先在官网注册。
18+
如果还没有账号,需要先在官网注册。
1819

1920
完成注册并登录后,新建项目,然后就能看到快速开始,照着指南一步一步走就可以,你的api key都会在里面!为了方便我把指南的内容都搬到这了
2021

@@ -24,7 +25,7 @@ tags:
2425

2526
```bash
2627
pip install swanlab
27-
````
28+
```
2829

2930
## 3. 登录 SwanLab
3031

@@ -44,7 +45,6 @@ swanlab: Paste an API key from your profile and hit enter, or press 'CTRL-C' to
4445

4546
将你从官网用户设置页面复制的 API Key 粘贴进去即可完成登录。([docs.swanlab.cn](https://docs.swanlab.cn/en/guide_cloud/general/quick-start.html))
4647

47-
4848
## 4. 提交实验
4949

5050
```python
@@ -84,9 +84,9 @@ swanlab.finish()
8484
---
8585

8686
## 5. 查看结果!
87-
运行了代码之后,可以导航到新创建的项目,比较不同的实验和它们的指标。
8887

88+
运行了代码之后,可以导航到新创建的项目,比较不同的实验和它们的指标。
8989

9090
## 参考文献
91-
官方文档:[Quick Start 指南](https://docs.swanlab.cn/en/guide_cloud/general/quick-start.html)
9291

92+
官方文档:[Quick Start 指南](https://docs.swanlab.cn/en/guide_cloud/general/quick-start.html)

0 commit comments

Comments
 (0)