aboutsummaryrefslogtreecommitdiff
path: root/pandoc-blog/generate-index.py
diff options
context:
space:
mode:
authorArun Isaac2025-04-07 15:57:53 +0100
committerArun Isaac2025-04-07 15:57:53 +0100
commita760bff3efa44c282ed119032a6831bdaac79e7b (patch)
tree44a74e8d59b44065ab5b3a3270ba57827ec5fc1a /pandoc-blog/generate-index.py
downloadgexp-make-a760bff3efa44c282ed119032a6831bdaac79e7b.tar.gz
gexp-make-a760bff3efa44c282ed119032a6831bdaac79e7b.tar.lz
gexp-make-a760bff3efa44c282ed119032a6831bdaac79e7b.zip
Initial commit
Diffstat (limited to 'pandoc-blog/generate-index.py')
-rw-r--r--pandoc-blog/generate-index.py20
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)