2022-12-24 17:42:40 +01:00
|
|
|
import os
|
|
|
|
import time
|
|
|
|
|
|
|
|
header = {
|
|
|
|
"author": "spanskiduh",
|
|
|
|
}
|
|
|
|
|
2023-02-27 21:59:02 +01:00
|
|
|
MD_NOTES_DIR = "../../../md-notes/"
|
2022-12-24 17:42:40 +01:00
|
|
|
POSTS_DIR = "../content/posts/"
|
|
|
|
|
|
|
|
def main():
|
|
|
|
# List all files in md-notes directory
|
|
|
|
for filename in os.listdir(MD_NOTES_DIR):
|
|
|
|
# Check if file is md file
|
|
|
|
if filename.endswith(".md"):
|
|
|
|
# Opent the file and read it
|
|
|
|
with open(MD_NOTES_DIR + filename, "r") as f:
|
|
|
|
# Read the file
|
|
|
|
file = f.read()
|
|
|
|
header["title"] = filename[:-3]
|
|
|
|
header["description"] = f"click to read about {filename[:-3]}"
|
|
|
|
date_modified = os.path.getmtime(MD_NOTES_DIR + filename)
|
|
|
|
header["date"] = time.strftime("%Y-%m-%d", time.localtime(date_modified))
|
|
|
|
|
|
|
|
# Add the header to the file for hugo to parse
|
|
|
|
file = f"""\r
|
|
|
|
+++
|
|
|
|
date="{header["date"]}"
|
|
|
|
author="{header["author"]}"
|
|
|
|
title="{header["title"]}"
|
|
|
|
description="{header["description"]}"
|
|
|
|
+++
|
|
|
|
{file}"""
|
|
|
|
# Write the file to proc directory
|
|
|
|
with open(POSTS_DIR + filename, "w") as f:
|
|
|
|
f.write(file)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|