From 70625ce62aba43e586901d340ae81c2830d9fbc6 Mon Sep 17 00:00:00 2001 From: LarsVomMars Date: Thu, 26 Dec 2024 23:41:15 +0100 Subject: init --- .scripts/transform.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .scripts/transform.py (limited to '.scripts/transform.py') diff --git a/.scripts/transform.py b/.scripts/transform.py new file mode 100644 index 0000000..f66023d --- /dev/null +++ b/.scripts/transform.py @@ -0,0 +1,26 @@ +from pathlib import Path +from datetime import datetime + +def transform(path: Path): + last_write_date = path.stat().st_mtime + last_write_date = datetime.fromtimestamp(last_write_date).strftime("%Y-%m-%d") + print(f"Transforming {path} last modified at {last_write_date}") + content = path.read_text() + title = content.splitlines()[0][1:].strip() + print(f"Title: {title}") + content = f"""--- +title: "{title}" +pubDate: "{last_write_date}" +--- +{content} +""" + path.write_text(content) + pass + + +blogs = Path("./src/content/blog") +for blog in blogs.iterdir(): + if blog.is_dir(): + for blog_file in blog.iterdir(): + if blog_file.is_file(): + transform(blog_file) \ No newline at end of file -- cgit v1.2.3