You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1005 B
Python
36 lines
1005 B
Python
import json
|
|
import frontmatter
|
|
import os
|
|
|
|
|
|
def dump():
|
|
# list all the folders
|
|
folders = [
|
|
name
|
|
for name in os.listdir()
|
|
if os.path.isdir(os.path.join("", name))
|
|
and not name.startswith(".")
|
|
and not name == "miri-the-leader"
|
|
]
|
|
|
|
print(folders)
|
|
|
|
contents = []
|
|
|
|
for folder in folders:
|
|
with open(f"{folder}/contents.md", "r") as f:
|
|
metadata, body = frontmatter.parse(f.read())
|
|
for content in metadata["contents"]:
|
|
if type(content) == dict and content["img"]:
|
|
postit = {
|
|
"title": metadata["title"],
|
|
"description": content["alt"],
|
|
"img": content["img"],
|
|
}
|
|
else:
|
|
postit = {"title": metadata["title"], "description": content}
|
|
contents.append(postit)
|
|
|
|
with open("postit/contents.json", "w") as f:
|
|
f.write(json.dumps(contents))
|