Skip to content

Commit 2e559e0

Browse files
committed
Restructure repo: split apps/docs and packages/theme
Reorganize the project into a pnpm workspace: move the VitePress site into apps/docs and the theme into packages/theme (with its own package.json). Update root package.json scripts to build/dev the workspace, adjust pnpm-workspace.yaml and pnpm-lock. Update CI and deploy workflows, vercel.json and paths to use apps/docs/dist. Add ARCHITECTURE.md and README docs about the new layout. Introduce Disclaimer and FontSwitcher components and analytics toggle in the theme; adjust theme/config, exports, and styles. Rename/move many example/* files into apps/docs, update eslint ignores, and remove legacy example package files.
1 parent 0bf7f00 commit 2e559e0

126 files changed

Lines changed: 777 additions & 978 deletions

File tree

Some content is hidden

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

.all-contributorsrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,6 @@
5959
"skipCi": true,
6060
"repoType": "github",
6161
"repoHost": "https://github.com",
62-
"projectName": "vitepress-theme-project-trans",
63-
"projectOwner": "mtfreport"
62+
"projectName": "MtF.Report",
63+
"projectOwner": "MtFReport-Team"
6464
}

.github/workflows/SyncTransMarkdown.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ jobs:
1818
1919
- name: Copy and commit file
2020
run: |
21-
mkdir -p example/docs/zh-cn/references
22-
cp temp_notes/trans.md example/docs/zh-cn/references/sbchild.md
21+
mkdir -p apps/docs/zh-cn/references
22+
cp temp_notes/trans.md apps/docs/zh-cn/references/sbchild.md
2323
git config --global user.name 'github-actions[bot]'
2424
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
25-
git add example/docs/zh-cn/references/sbchild.md
25+
git add apps/docs/zh-cn/references/sbchild.md
2626
git commit -m "chore: sync sbchild.md from sb-child/notes" || echo "No changes"
2727
git push

.github/workflows/deploy.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- name: Setup pnpm
3131
uses: pnpm/action-setup@v3
3232
with:
33-
version: 9
33+
version: 10.4.1
3434

3535
- name: Setup Node.js
3636
uses: actions/setup-node@v4
@@ -45,12 +45,12 @@ jobs:
4545
run: pnpm install
4646

4747
- name: Build VitePress site
48-
run: pnpm build && cd example && pnpm build # 或 pnpm build,取决于你的 package.json
48+
run: pnpm build
4949

5050
- name: Upload build artifact
5151
uses: actions/upload-pages-artifact@v3
5252
with:
53-
path: example/dist
53+
path: apps/docs/dist
5454

5555
deploy:
5656
name: Deploy to GitHub Pages

ARCHITECTURE.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# MtF.Report 仓库架构
2+
3+
本仓库采用 pnpm workspace 管理,将“站点内容”和“VitePress 主题实现”分为两个独立工作区。
4+
5+
```text
6+
MtF.Report/
7+
├── apps/
8+
│ └── docs/ # MtF.Report 文档站
9+
│ ├── .vitepress/ # 站点配置与品牌样式
10+
│ ├── public/ # 静态资源
11+
│ ├── en/ # 英文内容
12+
│ ├── zh-cn/ # 简体中文内容
13+
│ └── zh-tw/ # 繁体中文内容
14+
├── packages/
15+
│ └── theme/ # 可复用的 VitePress 主题包
16+
│ └── src/
17+
│ ├── components/ # 页面与布局组件
18+
│ ├── plugins/ # VitePress 内容加载器
19+
│ ├── utils/ # 配置上下文与路径工具
20+
│ ├── config.ts # VitePress 服务端配置入口
21+
│ └── theme.ts # VitePress 客户端主题入口
22+
├── package.json # 工作区统一命令
23+
├── pnpm-workspace.yaml # 工作区声明
24+
└── vercel.json # 生产部署配置
25+
```
26+
27+
## 依赖方向
28+
29+
```mermaid
30+
flowchart LR
31+
Root["根工作区脚本"] --> Theme["packages/theme"]
32+
Root --> Docs["apps/docs"]
33+
Docs --> Theme
34+
DocsConfig["apps/docs/.vitepress/config.ts"] --> ServerEntry["theme/config.ts"]
35+
DocsTheme["apps/docs/.vitepress/theme/index.ts"] --> ClientEntry["theme/theme.ts"]
36+
ClientEntry --> Layout["Layout 与 Components"]
37+
ServerEntry --> Loaders["Sidebar 与 Content Loaders"]
38+
```
39+
40+
依赖只允许从 `apps/docs` 指向 `packages/theme`。主题包不能反向读取站点内容,也不应硬编码 MtF.Report 的文案、品牌资源或部署路径。
41+
42+
## 运行链路
43+
44+
1. `apps/docs/.vitepress/config.ts` 创建站点配置,并通过 `withThemeContext` 把站点参数传给主题配置入口。
45+
2. `packages/theme/src/config.ts` 组装 Markdown 插件、侧边栏、内容统计和 Vite 插件。
46+
3. `apps/docs/.vitepress/theme/index.ts` 加载主题客户端入口。
47+
4. `packages/theme/src/theme.ts` 扩展 VitePress 默认主题并挂载自定义布局与客户端插件。
48+
5. `packages/theme/src/Layout.vue` 将页面信息、版权信息、页脚和辅助阅读组件插入 VitePress 插槽。
49+
50+
## 目录职责
51+
52+
### `apps/docs`
53+
54+
- Markdown 内容、翻译和栏目结构。
55+
- MtF.Report 的颜色、字体、Logo、favicon 等品牌资源。
56+
- 域名、导航、语言、免责声明和部署输出目录等站点配置。
57+
58+
### `packages/theme`
59+
60+
- 通用布局和 Vue 组件。
61+
- VitePress/Markdown/Vite 插件组合。
62+
- 侧边栏生成、内容加载和配置上下文。
63+
- 对外导出的 `config``theme``components``utils` 四个入口。
64+
65+
### 根目录
66+
67+
- 统一开发、构建、检查命令。
68+
- workspace、CI、Vercel 和代码规范配置。
69+
- 项目级说明文档。
70+
71+
## 常用命令
72+
73+
```bash
74+
pnpm install
75+
pnpm dev
76+
pnpm build
77+
pnpm lint
78+
pnpm typecheck
79+
```
80+
81+
`pnpm build` 会先构建主题包,再构建文档站,确保站点始终使用最新的本地主题产物。
82+
83+
## 修改约定
84+
85+
- 新文章和翻译放到 `apps/docs/<locale>/`
86+
- 品牌样式放到 `apps/docs/.vitepress/theme/style.css`
87+
- 可被其他站点复用的组件或构建能力放到 `packages/theme/src/`
88+
- 新增主题公开能力时,同步维护 `packages/theme/package.json``exports`
89+
- 调整目录时同步检查 GitHub Actions、Vercel 和内容同步脚本中的路径。

README.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,30 @@ MtF.Report 是一个致力于研究与支持中国青少年跨性别女性(MtF
1212

1313
本项目贡献者包括跨性别者等多元文化群体,请在贡献时尊重她们,使用友善礼貌的词语。
1414

15+
## 仓库结构
16+
17+
仓库已经按 pnpm workspace 拆分为两部分:
18+
19+
- `apps/docs`:MtF.Report 的 VitePress 文档站、各语言内容和品牌资源。
20+
- `packages/theme`:文档站使用的 VitePress 主题、组件和构建配置。
21+
22+
完整的模块职责、依赖方向与运行链路见 [ARCHITECTURE.md](./ARCHITECTURE.md)
23+
24+
## 本地开发
25+
26+
```bash
27+
pnpm install
28+
pnpm dev
29+
```
30+
31+
构建、代码检查和类型检查分别使用:
32+
33+
```bash
34+
pnpm build
35+
pnpm lint
36+
pnpm typecheck
37+
```
38+
1539
<div align="center">
1640
<img src="https://komarev.com/ghpvc/?username=mtfreport" style="display:inline-block;vertical-align:middle;" />
1741
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
@@ -27,7 +51,7 @@ MtF.Report 是一个致力于研究与支持中国青少年跨性别女性(MtF
2751
<table>
2852
<tbody>
2953
<tr>
30-
<td align="center" valign="top" width="14.28%"><a href="https://chiyu.it"><img src="https://avatars.githubusercontent.com/u/109492503?v=4?s=100" width="100px;" alt="池鱼鱼"/><br /><sub><b>池鱼鱼</b></sub></a><br /><a href="https://github.com/mtfreport/vitepress-theme-project-trans/commits?author=kazukokawagawa" title="Code">💻</a> <a href="#translation-kazukokawagawa" title="Translation">🌍</a></td>
54+
<td align="center" valign="top" width="14.28%"><a href="https://chiyu.it"><img src="https://avatars.githubusercontent.com/u/109492503?v=4?s=100" width="100px;" alt="池鱼鱼"/><br /><sub><b>池鱼鱼</b></sub></a><br /><a href="https://github.com/MtFReport-Team/MtF.Report/commits?author=kazukokawagawa" title="Code">💻</a> <a href="#translation-kazukokawagawa" title="Translation">🌍</a></td>
3155
<td align="center" valign="top" width="14.28%"><a href="https://github.com/CodingXiaoheng"><img src="https://avatars.githubusercontent.com/u/216361016?v=4?s=100" width="100px;" alt="CodingXiaoheng"/><br /><sub><b>CodingXiaoheng</b></sub></a><br /><a href="#content-CodingXiaoheng" title="Content">🖋</a></td>
3256
<td align="center" valign="top" width="14.28%"><a href="https://github.com/FengzihangCode"><img src="https://avatars.githubusercontent.com/u/91676896?v=4?s=100" width="100px;" alt="DannyFeng"/><br /><sub><b>DannyFeng</b></sub></a><br /><a href="#translation-FengzihangCode" title="Translation">🌍</a></td>
3357
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Hoshroin"><img src="https://avatars.githubusercontent.com/u/31343983?v=4?s=100" width="100px;" alt="Hosh"/><br /><sub><b>Hosh</b></sub></a><br /><a href="#research-Hoshroin" title="Research">🔬</a> <a href="#promotion-Hoshroin" title="Promotion">📣</a></td>
@@ -65,4 +89,4 @@ MtF.Report 是一个致力于研究与支持中国青少年跨性别女性(MtF
6589
<!-- markdownlint-restore -->
6690
<!-- prettier-ignore-end -->
6791

68-
该项目采用了 Project Trans VitePress 主题 <https://github.com/project-trans/vitepress-theme-project-trans>
92+
该项目采用并维护了基于 Project Trans VitePress 主题的本地主题包:<https://github.com/project-trans/vitepress-theme-project-trans>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ dist
1212
dist-ssr
1313
*.local
1414

15-
docs/.vitepress/cache
16-
components.d.ts
15+
.vitepress/cache
16+
.vitepress/components.d.ts
Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,25 @@ const nav: DefaultTheme.NavItem[] = [
1515
// {
1616
// text: '校园版块投稿指南',
1717
// link: '/contributor-guide/doc.md',
18-
// },
19-
// {
20-
// text: '其他投稿指南',
21-
// link: '/contributor-guide/other.md',
22-
// },
23-
// {
24-
// text: '校园版块贡献模板',
25-
// link: '/contributor-guide/docTemplate.md',
18+
// },
19+
// {
20+
// text: '其他投稿指南',
21+
// link: '/contributor-guide/other.md',
22+
// },
23+
// {
24+
// text: '校园版块贡献模板',
25+
// link: '/contributor-guide/docTemplate.md',
2626
// },
2727
// ],
28-
//},
28+
// },
2929
]
3030

3131
const baseConfig = {
3232
useTitleFromFrontmatter: true,
3333
useFolderTitleFromIndexFile: true,
3434
useFolderLinkFromIndexFile: true,
3535
collapsed: true,
36-
documentRootPath: '/docs',
36+
documentRootPath: '/',
3737
} satisfies Partial<SidebarOptions>
3838

3939
const sidebarOptions = [
@@ -45,43 +45,45 @@ const sidebarOptions = [
4545
},
4646
{
4747
...baseConfig,
48-
scanStartPath: 'en', // 扫描 docs/en 下的 md
49-
resolvePath: '/en/', // 映射到 /en/ 下
48+
scanStartPath: 'en',
49+
resolvePath: '/en/',
5050
sortMenusByFrontmatterOrder: true,
5151
},
5252
{
5353
...baseConfig,
54-
scanStartPath: 'zh-tw', // 扫描 docs/en 下的 md
55-
resolvePath: '/zh-tw/', // 映射到 /en/ 下
54+
scanStartPath: 'zh-tw',
55+
resolvePath: '/zh-tw/',
5656
sortMenusByFrontmatterOrder: true,
57-
}
57+
},
5858
]
5959

6060
const themeConfig: ThemeContext = {
6161
siteTitle: 'MtF.Report',
6262
siteDescription: '让世界看见她们',
63+
hostName: 'https://mtf.report',
6364
// baseUrl: '/',
6465
/** Repo */
65-
githubRepoLink: 'https://github.com/mtfreport/vitepress-theme-project-trans',
66+
githubRepoLink: 'https://github.com/MtFReport-Team/MtF.Report',
6667
/** vitepress 根目录 */
67-
rootDir: 'docs',
68+
rootDir: '.',
6869
/** 文档所在目录(目前似未使用此项) */
6970
include: ['zh-cn', 'en'],
7071
nav,
7172
sidebarOptions,
7273
// enableChangeLog: false,
7374
enableSuggestionBox: false,
75+
enableAnalytics: true,
7476
HideReadingTime: true, /* 隐藏字数和预计阅读时间 */
7577
HideLastUpdated: true, /* 隐藏最后更新时间 */
76-
//HideAuthors: true, /* 隐藏作者信息 */
78+
// HideAuthors: true, /* 隐藏作者信息 */
7779
// fontsBaseUrl: 'http://localhost:8788', // For local development with wrangler pages dev
7880
disclaimerPaths: [
7981
{
8082
path: '/zh-cn/',
8183
summaryHtml: 'MtF.Report 中的内容,仅供参考。可能存在过时或不准确的信息,请谨慎甄别。',
82-
// detailHtml: '<p>RLE.wiki「大学指南」中的内容,仅供参考。可能存在过时或不准确的信息,请谨慎甄别。</p>'
83-
// + '<p>「大学指南」板块中的内容,多数来自于读者投稿,并经编辑简单整理和形式审查后登载,主要体现其投稿者主观观点。不代表 RLE.wiki 编辑团队及我们的任何相关维护人员立场。</p>'
84-
// + '<p>若存在任何有误或不当内容,请联系 <a href="mailto:rlewiki@project-trans.org">rlewiki@project-trans.org</a>。</p>',
84+
// detailHtml: '<p>RLE.wiki「大学指南」中的内容,仅供参考。可能存在过时或不准确的信息,请谨慎甄别。</p>'
85+
// + '<p>「大学指南」板块中的内容,多数来自于读者投稿,并经编辑简单整理和形式审查后登载,主要体现其投稿者主观观点。不代表 RLE.wiki 编辑团队及我们的任何相关维护人员立场。</p>'
86+
// + '<p>若存在任何有误或不当内容,请联系 <a href="mailto:rlewiki@project-trans.org">rlewiki@project-trans.org</a>。</p>',
8587
},
8688
],
8789
enableDisclaimer: true,
@@ -119,10 +121,14 @@ const themeConfig: ThemeContext = {
119121
export default withThemeContext(themeConfig, () => {
120122
return {
121123
...genConfig(),
122-
outDir: '../dist',
124+
ignoreDeadLinks: [
125+
/^\.\/(?:README|sleep|emo|medicine2|trans-story)$/,
126+
/^\.\/(?:mention|moments)\//,
127+
],
128+
outDir: './dist',
123129
sitemap: {
124-
hostname: 'https://mtf.report',
125-
lastmodDateOnly: true
126-
}
130+
hostname: 'https://mtf.report',
131+
lastmodDateOnly: true,
132+
},
127133
}
128134
})
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
// docs/.vitepress/theme/index.ts
21
// https://vitepress.dev/guide/custom-theme
32
import PtjsTheme from '@project-trans/vitepress-theme-project-trans/theme'
4-
import DefaultTheme from 'vitepress/theme-without-fonts'
53
import 'uno.css'
64
import './style.css'
75

8-
export default {
9-
extends: PtjsTheme,DefaultTheme
10-
}
6+
export default PtjsTheme

0 commit comments

Comments
 (0)