Skip to content

Commit d0bf05a

Browse files
Merge pull request #27 from MengyangGao/main
Fix MkDocs “Edit on GitHub” links
2 parents d56ba3c + 6ec0898 commit d0bf05a

4 files changed

Lines changed: 47 additions & 2 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
docs/
1+
docs/
2+
__pycache__/
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
## 一、课程内容
2+
待补充
3+
4+
## 二、考核方式
5+
待补充
6+
7+
## 三、修读攻略
8+
202X级XXX:
9+
10+
- 待补充
11+
- 待补充
12+
13+
## 四、注意事项
14+
待补充

hooks.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from pathlib import PurePosixPath
2+
3+
4+
def on_files(files, config):
5+
for file in files:
6+
src_uri = file.src_uri
7+
8+
# docs/index.md 在 MkDocs 内部通常表现为 index.md
9+
# 目标:/edit/main/README.md
10+
if src_uri == "index.md":
11+
file.edit_uri = "README.md"
12+
continue
13+
14+
path = PurePosixPath(src_uri)
15+
16+
# 生成页:
17+
# 01-基础必修课/C++编程基础.md
18+
#
19+
# 原始源文件:
20+
# 01-基础必修课/C++编程基础/README.md
21+
if path.suffix == ".md" and len(path.parts) >= 2:
22+
course_group = path.parts[0]
23+
course_name = path.stem
24+
file.edit_uri = f"{course_group}/{course_name}/README.md"
25+
26+
return files

mkdocs.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
site_name: 华南理工未来技术学院课程攻略
22
theme: readthedocs
3-
repo_url: https://github.com/OpenFuTech/SCUT-FT-Guide
3+
repo_url: https://github.com/OpenFuTech/SCUT-FT-Guide
4+
edit_uri: edit/main/
5+
6+
hooks:
7+
- hooks.py

0 commit comments

Comments
 (0)