# 5. 重组 Front-matter order = ['title', 'date', 'updated', 'cover', 'description', 'tags', 'categories'] new_fm_lines = [] for k in order: if k in fm_dict: v = fm_dict[k] ifisinstance(v, list): new_fm_lines.append(f"{k}:") for item in v: new_fm_lines.append(f" {item}") else: new_fm_lines.append(f"{k}: {v}") final_content = f"---\n{chr(10).join(new_fm_lines)}\n---{new_body}" withopen(file_path, 'w', encoding='utf-8') as f: f.write(final_content)
if __name__ == "__main__": iflen(sys.argv) > 1: for f in sys.argv[1:]: if f.endswith('.md'): process_markdown(f) else: for root, dirs, files in os.walk('.'): ifany(x in root for x in ['.github', '.git', 'node_modules']): continue for file in files: if file.endswith('.md'): process_markdown(os.path.join(root, file))