diff options
Diffstat (limited to 'pandoc-blog/generate-index.py')
-rw-r--r-- | pandoc-blog/generate-index.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/pandoc-blog/generate-index.py b/pandoc-blog/generate-index.py new file mode 100644 index 0000000..3e73f27 --- /dev/null +++ b/pandoc-blog/generate-index.py @@ -0,0 +1,20 @@ +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) |