blob: 44aa7564582768a3031ed668ff4eff0cbcdbcef0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#!/usr/bin/env python3
from parse_frontmatter import parse_frontmatter
from pathlib import Path
def generate_post_index():
script_dir = Path(__file__).parent.resolve()
posts_directory = script_dir / "../content/posts"
posts = []
for file in posts_directory.iterdir():
if file.is_file() and file.name != "index.md":
frontmatter=parse_frontmatter(file.resolve())
frontmatter["filename"] = file.name
if frontmatter["draft"]:
continue
posts.append(frontmatter)
sorted_posts = sorted(posts, key=lambda x: x["created"], reverse=True)
for i in sorted_posts:
html_file = i['filename'].replace(".md", ".html")
print(f"<time>{i['created']}:</time> [{i['title']}](/posts/{html_file})\n")
print("""---
title: "Posts"
slug: "posts"
css: |
time {
font-size: 16px;
color: #bbbbbb;
padding-right: 0.5em;
}
---""")
generate_post_index()
|