Skip to content

Commit cc7ccf5

Browse files
committed
edit功能
1 parent 730740d commit cc7ccf5

3 files changed

Lines changed: 72 additions & 9 deletions

File tree

docs/intro/edit.md

Lines changed: 51 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,58 @@
1-
# 参与编辑
1+
# 编辑页面说明
22

3-
感谢你愿意为Starship作出贡献。
3+
感谢你愿意为 Starship 作出贡献!🎉
44

5-
不过,在正式参与编辑前,请确保你了解[贡献指南](contribute.md)[格式手册](format.md)的内容。以免造成不必要的麻烦。
5+
在跳转至 GitHub 编辑页面之前,请确保你已经阅读了以下内容:
66

7-
阅读完成后,请点击下方按钮跳转到GitHub找到对应文件开始编辑。
7+
## 参与编辑前必读
88

9-
<button style="padding:.75em 1.25em;display:inline-block;line-height:1;text-decoration:none;white-space:nowrap;cursor:pointer;border:1px solid #42b983;border-radius:5px;background:#42b983;color:#fff;outline:none;font-size:.75em" onclick="openReferenceURL()"><b>开始编辑</b></button>
9+
- **阅读贡献指南**
10+
11+
请先阅读 [贡献指南](contribute.md),了解我们的编辑规范和流程。
1012

11-
---
13+
- **查看格式手册**
14+
15+
为保证内容的统一性,请参考 [格式手册](format.md)
1216

13-
还没有使用过GitHub?请参看[如何使用GitHub](how-to-use-GitHub.md)
17+
- **GitHub 使用指南**
18+
19+
如果你还不熟悉 GitHub 的编辑流程,请先阅读 [如何使用 GitHub](how-to-use-GitHub.md)
1420

15-
无法使用GitHub?请参看[其它贡献方式](contribute.md)
21+
## 注意事项
22+
23+
- 请在编辑前仔细核对内容的准确性
24+
- 保持格式与原文一致
25+
- 提交前检查是否有遗漏
26+
27+
<script>
28+
// 获取URL参数中的page值
29+
function getPageParam() {
30+
const params = new URLSearchParams(window.location.search);
31+
return params.get('page');
32+
}
33+
34+
// 生成GitHub编辑链接并跳转
35+
function openReferenceURL() {
36+
const pageUrl = getPageParam();
37+
if (!pageUrl) {
38+
alert('未检测到页面路径参数,请从内容页面点击编辑按钮。');
39+
return;
40+
}
41+
42+
// 移除开头的斜杠和末尾的斜杠
43+
let cleanPath = pageUrl.replace(/^\/|\/$/g, '');
44+
45+
// 移除 .md 扩展名(如果有的话)
46+
cleanPath = cleanPath.replace(/\.md$/, '');
47+
48+
// 跳转到GitHub编辑页面
49+
window.location.href = 'https://github.com/HowCam/howcam.github.io/edit/main/docs/' + cleanPath + '.md';
50+
}
51+
</script>
52+
<div style="margin: 2rem 0;">
53+
<button style="padding:.75em 1.25em; display:inline-block; line-height:1; text-decoration:none; white-space:nowrap; cursor:pointer; border:1px solid #42b983; border-radius:5px; background:#42b983; color:#fff; outline:none; font-size:.75em" onclick="openReferenceURL()"><b>开始编辑</b></button>
54+
</div>
55+
56+
## 无法使用 GitHub?
57+
58+
如果你无法使用 GitHub 编辑,请参考 [其它贡献方式](contribute.md)

overrides/main.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
{% block announce %}
44
<div class="md-announce">
5-
<p>🎉 本站现已启用新域名:starship.howcam.top 🎉</p>
5+
<p>🎉本站现已启用新域名:starship.howcam.top🎉</p>
66
</div>
77
{% endblock %}

overrides/partials/actions.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{# 自定义编辑按钮 - 替换原生actions.html #}
2+
{% if page.edit_url %}
3+
{% if "content.action.edit" in features %}
4+
<a href="/intro/edit/?page={{ page.url }}" title="{{ lang.t('action.edit') }}" class="md-content__button md-icon" rel="edit">
5+
{% set icon = config.theme.icon.edit or "material/file-edit-outline" %}
6+
{% include ".icons/" ~ icon ~ ".svg" %}
7+
</a>
8+
{% endif %}
9+
{% if "content.action.view" in features %}
10+
{% if "/blob/" in page.edit_url %}
11+
{% set part = "blob" %}
12+
{% else %}
13+
{% set part = "edit" %}
14+
{% endif %}
15+
<a href="{{ page.edit_url | replace(part, 'raw') }}" title="{{ lang.t('action.view') }}" class="md-content__button md-icon">
16+
{% set icon = config.theme.icon.view or "material/file-eye-outline" %}
17+
{% include ".icons/" ~ icon ~ ".svg" %}
18+
</a>
19+
{% endif %}
20+
{% endif %}

0 commit comments

Comments
 (0)