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):
166166 if not os .path .exists (docs_dir ):
167167 os .makedirs (docs_dir )
168168 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+
169180 # 开启评论
170181 """
171182 ---
172183 comments: true
173184 ---
174185 """
175- content = '---\n comments: true\n ---\n \n ' + content
186+ content = f '---\n comments: true\n { tag_headers } ---\n \n ' + content
176187 with open (new_path , "w" , encoding = "utf-8" ) as f :
177188 f .write (content )
178189
You can’t perform that action at this time.
0 commit comments