Files
Website-2026/scripts/generate_blog_manifest.py
2026-07-09 10:17:57 +02:00

24 lines
686 B
Python

#!/usr/bin/env python3
"""
Generate `blog/manifest.json` from the text files present in the blog/ folder.
Run this in the project root to refresh the manifest after adding/removing blog entries.
"""
import os
import json
BASEDIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
BLOGDIR = os.path.join(BASEDIR, 'blog')
def main():
exts = ('.txt', '.text')
files = [f for f in sorted(os.listdir(BLOGDIR)) if f.lower().endswith(exts)]
out = os.path.join(BLOGDIR, 'manifest.json')
with open(out, 'w', encoding='utf-8') as fh:
json.dump(files, fh, indent=2)
print(f'Wrote {len(files)} entries to {out}')
if __name__ == '__main__':
main()