Skip to content

Commit e221265

Browse files
ShizuhaAkiCopilot
andauthored
fear: Better editing experience (#26)
* edit landing * feat: more contributing guide * fix: minor grammar problems * fix: grammar error Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix: punc error Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 3cec10a commit e221265

9 files changed

Lines changed: 102 additions & 6 deletions

File tree

docs/.vitepress/config/zh.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const zh = defineConfig({
1010
sidebar: sidebarGuide(),
1111

1212
editLink: {
13-
pattern: 'https://github.com/FDUCSLG/CS101/edit/main/docs/:path',
13+
pattern: '/edit-landing.md?path=FDUCSLG/CS101/edit/main/docs/:path',
1414
text: '在 GitHub 上编辑此页面'
1515
},
1616

@@ -90,7 +90,8 @@ function sidebarGuide(): DefaultTheme.Sidebar {
9090
{ text: "发行版相关", link: "/linux-and-shell/on-distros" },
9191
],
9292
},
93-
{ text: "关于 CS101 项目", link: "/project" },
94-
{ text: "关于我们", link: "/team" },
93+
{ text: "贡献指南", link: "/project/contributing" },
94+
{ text: "关于 CS101 项目", link: "/project/project" },
95+
{ text: "关于我们", link: "/project/team" },
9596
]
9697
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<script setup>
2+
// extract ?path=... argument
3+
const paramsString = window.location.search;
4+
const params = new URLSearchParams(paramsString)
5+
const path = params.get('path')
6+
7+
// fallback if not present
8+
const editUrl = path
9+
? `https://github.com/${path}`
10+
: 'https://github.com/FDUCSLG/CS101'
11+
</script>
12+
13+
<template>
14+
<a
15+
v-if="editUrl"
16+
:href="editUrl"
17+
target="_blank"
18+
class="vp-button"
19+
style="display:inline-block;padding:0.4em 1em;
20+
background:#0366d6;color:white;
21+
border-radius:4px;text-decoration:none;">
22+
开始编辑
23+
</a>
24+
</template>

docs/.vitepress/theme/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import 'vitepress-plugin-codeblocks-fold/style/index.css';
2929
import '@nolebase/vitepress-plugin-page-properties/client/style.css';
3030
import '@nolebase/vitepress-plugin-enhanced-mark/client/style.css';
3131
import Confetti from "./components/Confetti.vue";
32-
32+
import EditButton from "./components/EditButton.vue";
3333
import Hero from '../theme/Layout.vue';
3434
import NCard from './components/NCard.vue';
3535

@@ -48,6 +48,7 @@ export default {
4848
},
4949
enhanceApp({ app }) {
5050
app.component("Confetti", Confetti); //注册全局组件
51+
app.component("EditButton", EditButton);
5152
app.use(NolebaseEnhancedReadabilitiesPlugin, {
5253
spotlight: {
5354
disableHelp: true,

docs/edit-landing.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Edit Landing
2+
3+
欢迎您对 CS101 进行贡献!
4+
5+
如果不知道怎么做,您可以阅读[贡献指南](./project/contributing.md)
6+
7+
准备好后,点击下面的按钮开始编辑吧!
8+
9+
<EditButton/>

docs/index.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ hero:
1010
actions:
1111
- theme: brand
1212
text: 启动!
13-
link: /tools/markdown1.md
14-
13+
link: /project/welcome.md
1514
features:
1615
- icon: 📝
1716
title: 课程资源

docs/project/contributing.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# 贡献指南
2+
CS101 项目采用 GitHub 进行协作。您可以参考 [Git & GitHub](../tools/git-and-github.md) 这篇文档来学会基本操作。
3+
4+
要参与贡献,您需要一个 GitHub 账号(可以前往 [GitHub 的账号注册页面](https://github.com/signup) 注册),但不需要高超的 GitHub 技巧,即使你是一名新手,只要按照下面所述的步骤操作,也能够非常出色地完成编辑。
5+
6+
## 编辑的基本步骤
7+
简单来说,是这么几步:
8+
9+
1. 找到您想要编辑的页面;
10+
2. 滚动到最下方,点击 “在 GitHub 上编辑本页”,您会来到我们的编辑准备页面;
11+
3. 准备好后,点击 “开始编辑” 按钮跳转到 GitHub 的编辑器页面,您可在此进行编辑,编辑完后,在 Commit Message 框中,用以下的格式简要概括您的修改
12+
```
13+
type: brief summary of what you did
14+
```
15+
其中 `type` 为您此次所做的修改的类别。例如,如果是写作了新的内容,`type` 为 `feat`;如果是修复了过去的一个问题,`type` 为 `fix`。
16+
>[!INFO] 提示
17+
> 这是 Semantic/Conventional Commit Message 的要求。如果您想要了解更多的话,可以参考 [这个规范文档](https://www.conventionalcommits.org/en/v1.0.0/)。
18+
4. 点击 Propose Changes 按钮提交修改;
19+
5. 在下一个页面中,点击 Create Pull Request 按钮,在弹出的 Pull Request 详情页面中,简要叙述修改的内容;
20+
6. 大功告成!您只需要等待管理员审核并合并到主仓库中即可。
21+
22+
## 在本地进行编辑
23+
如果您想要在本地进行编辑的话,就需要一定的 `git` 相关知识。您可以参考 [Git & GitHub](../tools/git-and-github.md) 这篇文档。
24+
25+
不过,简单说来,您只需要做以下这些事情:
26+
27+
### 准备工作
28+
您应该先安装好 Node.js 环境。请参考 [Node官网](https://nodejs.org) 上的指南。
29+
30+
接着,fork 并 clone 本仓库,并配置环境
31+
```shell
32+
git clone https://github.com/<your-username>/CS101
33+
cd CS101
34+
npm install
35+
npm run docs:dev
36+
```
37+
38+
这样就可以在[http://localhost:5173](http://localhost:5173)实时预览您的编辑了。
39+
40+
### 修改工作
41+
每次修改前,您应当创建一个新的 branch,并在那里修改。
42+
43+
```shell
44+
git checkout -b my-branch-name
45+
git add .
46+
git commit -m "<type>: <brief commit message>"
47+
git push -u origin my-branch-name
48+
```
49+
50+
修改完后,将您的工作 commit 并 push 回上游,并开启一个 Pull Request 即可。
File renamed without changes.
File renamed without changes.

docs/project/welcome.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# 欢迎来到 CS101!
2+
3+
CS101 项目是复旦大学 FDUCSLG 社团推动发起的一项面向**所有人**的计算机通识入门指南。我们致力于成为一个免费,开放,持续更新的计算机基础知识整合站点。
4+
5+
## 项目组织
6+
目前,CS101 项目着重建设的是以下两个模块:
7+
8+
- FAQ101:以一问一答形式进行的计算机基础知识扫盲和常见问题解答。欢迎向我们提问!
9+
- Tools101:作为一个合格的计算机学术用户,你应该学会的常用工具。
10+
11+
## 贡献指南
12+
向 CS101 贡献并不困难!如果不知道怎么开始,欢迎参考[贡献指南](./contributing.md)

0 commit comments

Comments
 (0)