aboutsummaryrefslogtreecommitdiff
from pathlib import Path
import sys

index = sys.argv[1]
posts = sys.argv[2:]

posts_directory = "posts"

def strip_store_hash(filename):
    return filename[33:]

with open(index, "w") as index_file:
    for post in posts:
        with open(post) as post_file:
            for line in post_file:
                if line.startswith("title:"):
                    title = line.removeprefix("title:").strip()
                    slug = strip_store_hash(Path(post).stem)
                    print(f"- [{title}]({posts_directory}/{slug}.html)",
                          file=index_file)