18 lines
524 B
Python
18 lines
524 B
Python
import os
|
|
import re
|
|
|
|
POSTS_DIR = "content/posts"
|
|
post_files = sorted([f for f in os.listdir(POSTS_DIR) if f.endswith(".md")])
|
|
|
|
for pf in post_files:
|
|
with open(os.path.join(POSTS_DIR, pf), 'r', encoding='utf-8') as f:
|
|
content = f.read()
|
|
|
|
title_m = re.search(r'^title:\s*"?(.+?)"?$', content, re.M)
|
|
date_m = re.search(r'^date:\s*(.+)$', content, re.M)
|
|
|
|
title = title_m.group(1) if title_m else ""
|
|
date = date_m.group(1) if date_m else ""
|
|
print(f"[{pf}] Date: {date} | Title: {title}")
|
|
|