File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -166,13 +166,24 @@ def get_paths(dirs: str, m: int):
166
166
if not os .path .exists (docs_dir ):
167
167
os .makedirs (docs_dir )
168
168
new_path = os .path .join (docs_dir , f"{ num } .md" )
169
+
170
+ # 获取 tags
171
+ match = re .search (r'<!-- tags:(.*?) -->' , content )
172
+ tag_headers = ''
173
+ if match :
174
+ tags = match .group (1 ).split (',' )
175
+ if tags and tags != ['' ]:
176
+ tag_headers = "tags:\n "
177
+ tag_headers += "" .join ([f" - { tag } \n " for tag in tags ])
178
+ tag_headers += "\n "
179
+
169
180
# 开启评论
170
181
"""
171
182
---
172
183
comments: true
173
184
---
174
185
"""
175
- content = '---\n comments: true\n ---\n \n ' + content
186
+ content = f '---\n comments: true\n { tag_headers } ---\n \n ' + content
176
187
with open (new_path , "w" , encoding = "utf-8" ) as f :
177
188
f .write (content )
178
189
You can’t perform that action at this time.
0 commit comments