Skip to content

Commit f8b991c

Browse files
authored
Merge branch 'main' into test/remark
2 parents 2e80457 + 3615267 commit f8b991c

File tree

135 files changed

+7549
-516
lines changed

Some content is hidden

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

135 files changed

+7549
-516
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

CONTRIBUTING.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ pnpm dev
127127

128128
打开浏览器访问 [http://localhost:3000](http://localhost:3000)
129129

130-
修改 `docs/` 下的 `.md` `.mdx` 文件,会自动热更新。
130+
修改 `docs/` 下的 `.md` 文件,会自动热更新。
131131

132132
---
133133

@@ -155,7 +155,7 @@ pnpm postinstall # 同步必要的 Husky/Fumadocs 配置
155155
docxA 引用了 imgA 图片, 那么他们的文档结构应该是 `docxA.assets/imgA`:
156156

157157
```md
158-
docsA.mdx
158+
docsA.md
159159
docsA.assets/
160160
imgA
161161
```
@@ -199,35 +199,35 @@ tags:
199199
```
200200
📂 docs/
201201
├── 📂 computer-science/ # 计算机科学
202-
│ ├── 📄 index.mdx # 概述
202+
│ ├── 📄 index.md # 概述
203203
│ └── 📂 data-structures/ # 数据结构
204-
│ ├── 📄 index.mdx # 概述
204+
│ ├── 📄 index.md # 概述
205205
│ ├── 📂 array/ # 数组
206-
│ │ ├── 📄 index.mdx # 概述
207-
│ │ ├── 📄 01-static-array.mdx # 静态数组
208-
│ │ └── 📄 02-dynamic-array.mdx # 动态数组
206+
│ │ ├── 📄 index.md # 概述
207+
│ │ ├── 📄 01-static-array.md # 静态数组
208+
│ │ └── 📄 02-dynamic-array.md # 动态数组
209209
│ └── 📂 linked-list/ # 链表
210-
│ ├── 📄 index.mdx # 概述
211-
│ └── 📄 01-singly-linked-list.mdx # 单向链表
210+
│ ├── 📄 index.md # 概述
211+
│ └── 📄 01-singly-linked-list.md # 单向链表
212212
```
213213

214214
### URL 生成
215215

216216
文件结构会自动生成简洁的 URL:
217217

218-
- `docs/computer-science/index.mdx``/computer-science`
219-
- `docs/computer-science/data-structures/array/01-static-array.mdx``/computer-science/data-structures/array/static-array`
218+
- `docs/computer-science/index.md``/computer-science`
219+
- `docs/computer-science/data-structures/array/01-static-array.md``/computer-science/data-structures/array/static-array`
220220

221221
### 命名约定
222222

223223
**文件夹:**
224224

225225
- 使用 `kebab-case` 命名: `computer-science`, `data-structures`
226-
- 每个主题文件夹应该有一个 `index.mdx` 文件作为概述
226+
- 每个主题文件夹应该有一个 `index.md` 文件作为概述
227227

228228
**文件:**
229229

230-
- 使用 `kebab-case` 命名: `static-array.mdx`
230+
- 使用 `kebab-case` 命名: `static-array.md`
231231
- 使用数字前缀排序: `01-`, `02-`
232232
- 前缀会自动从最终 URL 中移除
233233

README.en.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,24 @@
22
<a href="./README.md">简体中文</a> | <a href="./README.en.md">English</a>
33
</p>
44

5-
# Involution Hell Knowledge Base
5+
<p align="center">
6+
<a href="https://involutionhell.github.io">
7+
<img src="./public/mascot.svg" width="150">
8+
</a>
9+
</p>
10+
<p align="center"><a href="https://git.io/typing-svg"><img src="https://readme-typing-svg.demolab.com/?font=Fira+Code&weight=700&size=32&pause=1000&color=f6671b&center=true&vCenter=true&width=280&lines=Involution+Hell&duration=3000" alt="Typing SVG" /></a></p>
11+
12+
<p align="center">
13+
<img alt="Next.js" src="https://img.shields.io/badge/Next.js-000000?style=for-the-badge&logo=nextdotjs&logoColor=white" />
14+
<img alt="TypeScript" src="https://img.shields.io/badge/TypeScript-3178C6?style=for-the-badge&logo=typescript&logoColor=white" />
15+
<img alt="Tailwind CSS" src="https://img.shields.io/badge/Tailwind_CSS-38B2AC?style=for-the-badge&logo=tailwindcss&logoColor=white" />
16+
<img alt="Vercel" src="https://img.shields.io/badge/Vercel-000000?style=for-the-badge&logo=vercel&logoColor=white" />
17+
<a href="https://github.com/InvolutionHell/involutionhell.github.io/blob/main/LICENSE">
18+
<img alt="License" src="https://img.shields.io/github/license/InvolutionHell/involutionhell.github.io?style=for-the-badge&color=blue">
19+
</a>
20+
</p>
21+
22+
623

724
## 📋 About
825

@@ -64,6 +81,8 @@ Community contributions are always welcome:
6481

6582
For the full workflow, PR checklist, and UI collaboration guidelines, see [CONTRIBUTING.md](CONTRIBUTING.md).
6683

84+
[![Contributors](https://contrib.rocks/image?repo=InvolutionHell/involutionhell.github.io)](https://github.com/InvolutionHell/involutionhell.github.io/graphs/contributors)
85+
6786
## 🖼️ Documentation & Assets
6887

6988
The repo ships with automated image migration and linting. Learn how to place assets, reference images, and structure frontmatter in:

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,23 @@
22
<a href="./README.md">简体中文</a> | <a href="./README.en.md">English</a>
33
</p>
44

5-
# 内卷地狱知识库
5+
<p align="center">
6+
<a href="https://involutionhell.github.io">
7+
<img src="./public/mascot.svg" width="150">
8+
</a>
9+
</p>
10+
11+
<p align="center"><a href="https://git.io/typing-svg"><img src="https://readme-typing-svg.demolab.com/?font=Noto+Sans+SC&weight=700&size=32&pause=1000&color=f6671b&center=true&vCenter=true&width=420&lines=%E5%86%85%E5%8D%B7%E5%9C%B0%E7%8B%B1%E7%9F%A5%E8%AF%86%E5%BA%93&duration=3000" alt="Typing SVG" /></a></p>
12+
13+
<p align="center">
14+
<img alt="Next.js" src="https://img.shields.io/badge/Next.js-000000?style=for-the-badge&logo=nextdotjs&logoColor=white" />
15+
<img alt="TypeScript" src="https://img.shields.io/badge/TypeScript-3178C6?style=for-the-badge&logo=typescript&logoColor=white" />
16+
<img alt="Tailwind CSS" src="https://img.shields.io/badge/Tailwind_CSS-38B2AC?style=for-the-badge&logo=tailwindcss&logoColor=white" />
17+
<img alt="Vercel" src="https://img.shields.io/badge/Vercel-000000?style=for-the-badge&logo=vercel&logoColor=white" />
18+
<a href="https://github.com/InvolutionHell/involutionhell.github.io/blob/main/LICENSE">
19+
<img alt="License" src="https://img.shields.io/github/license/InvolutionHell/involutionhell.github.io?style=for-the-badge&color=blue">
20+
</a>
21+
</p>
622

723
## 📋 关于
824

@@ -74,6 +90,8 @@ pnpm dev
7490

7591
完整流程、PR 检查与 UI 协作约定请参考 [CONTRIBUTING.md](CONTRIBUTING.md)
7692

93+
[![Contributors](https://contrib.rocks/image?repo=InvolutionHell/involutionhell.github.io)](https://github.com/InvolutionHell/involutionhell.github.io/graphs/contributors)
94+
7795
## 🖼️ 文档与资产
7896

7997
仓库提供自动化图片迁移与 Lint 规则。如何放置图片、引用资产、撰写 Frontmatter 等细节已在贡献指南中整理:

app/components/Contribute.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const FILENAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9_-]+$/;
2727

2828
// 统一调用工具函数生成 GitHub 新建链接,路径规则与 Edit 按钮一致
2929
function buildGithubNewUrl(dirPath: string, filename: string, title: string) {
30-
const file = filename.endsWith(".mdx") ? filename : `${filename}.mdx`;
30+
const file = filename.endsWith(".md") ? filename : `${filename}.md`;
3131
const frontMatter = `---
3232
title: '${title || "New Article"}'
3333
description: ""

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/components/GiscusComments.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
1-
'use client';
1+
"use client";
22

3-
import Giscus from '@giscus/react';
3+
import Giscus from "@giscus/react";
44

55
interface GiscusCommentsProps {
66
className?: string;
7+
docId?: string | null;
78
}
89

9-
export function GiscusComments({ className }: GiscusCommentsProps) {
10+
export function GiscusComments({ className, docId }: GiscusCommentsProps) {
11+
const normalizedDocId = typeof docId === "string" ? docId.trim() : "";
12+
const useSpecificMapping = normalizedDocId.length > 0;
13+
1014
return (
1115
<div className={className}>
1216
<Giscus
1317
repo="InvolutionHell/involutionhell.github.io"
1418
repoId="R_kgDOPuD_8A"
1519
category="Comments"
1620
categoryId="DIC_kwDOPuD_8M4Cvip8"
17-
mapping="pathname"
21+
mapping={useSpecificMapping ? "specific" : "pathname"}
22+
term={useSpecificMapping ? normalizedDocId : undefined}
1823
strict="0"
1924
reactionsEnabled="1"
2025
emitMetadata="0"

app/components/Hero.tsx

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
import Link from "next/link";
2-
import { Button } from "../../components/ui/button";
3-
import { ExternalLink } from "lucide-react";
4-
import { Github as GithubIcon } from "./icons/Github";
52
import { ZoteroFeed } from "@/app/components/ZoteroFeed";
63
import { Contribute } from "@/app/components/Contribute";
74

@@ -55,23 +52,6 @@ export function Hero() {
5552
<p className="text-base md:text-lg text-muted-foreground">
5653
一个由开发者自发组织、免费开放的学习社区。降低门槛,避免无意义内卷,专注真实进步与乐趣。
5754
</p>
58-
59-
<div className="mt-8 flex flex-col sm:flex-row items-center justify-center gap-3">
60-
<Button asChild className="rounded-none">
61-
<a href="/docs/ai" target="_blank" rel="noopener noreferrer">
62-
访问知识库 <ExternalLink className="ml-2 h-4 w-4" />
63-
</a>
64-
</Button>
65-
<Button variant="outline" asChild className="rounded-none">
66-
<a
67-
href="https://github.com/involutionhell"
68-
target="_blank"
69-
rel="noopener noreferrer"
70-
>
71-
GitHub 仓库 <GithubIcon className="ml-2 h-4 w-4" />
72-
</a>
73-
</Button>
74-
</div>
7555
</div>
7656
{/* 投稿按钮 */}
7757
<Contribute />

0 commit comments

Comments
 (0)