Skip to content

Commit a611827

Browse files
committed
feat: add source
1 parent 466bab0 commit a611827

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

docs-en/lc/1.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ tags:
44
- Array
55
- Hash Table
66
edit_url: 'https://github.com/doocs/leetcode/edit/main/solution/0000-0099/0001.Two%20Sum/README_EN.md'
7+
source: Weekly Contest 1 Q1
8+
rating: 1234
79
---
810

911

docs/lc/1.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ tags:
66
- 数组
77
- 哈希表
88
rating: 1234
9+
source: 第 1 场周赛 Q1
910
---
1011

1112
# [1. 两数之和](https://leetcode.cn/problems/two-sum)

hooks/ext_info.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,26 @@ def on_page_markdown(markdown, page, config, files):
1212
rating = page.meta.get("rating")
1313
if not difficulty and not rating:
1414
return markdown
15+
source = page.meta.get("source")
1516
is_cn_problem_page = (page.edit_url or "").endswith("README.md")
1617
images = []
18+
if source:
19+
title = "来源" if is_cn_problem_page else "Source"
20+
images.append(
21+
f'<img src="https://img.shields.io/badge/{title}-{source}-4051B5?style=flat-square">'
22+
)
1723
if difficulty:
1824
title = "难度" if is_cn_problem_page else "Difficulty"
1925
images.append(
2026
f'<img src="https://img.shields.io/badge/{title}-{difficulty}-4051B5?style=flat-square">'
2127
)
2228
if rating:
23-
title = "难度分" if is_cn_problem_page else "Rating"
29+
title = "分数" if is_cn_problem_page else "Rating"
2430
images.append(
2531
f'<img src="https://img.shields.io/badge/{title}-{rating}-4051B5?style=flat-square">'
2632
)
2733
# 将 images 放到 <p> 标签中
28-
images_html = '<p>' + " ".join(images) + "</p>"
34+
images_html = "<p>" + " ".join(images) + "</p>"
2935
heading_pattern = re.compile(r"(^# .+?$)", re.MULTILINE)
3036
match = heading_pattern.search(markdown)
3137
if match:

0 commit comments

Comments
 (0)