-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.py
More file actions
92 lines (73 loc) · 1.98 KB
/
index.py
File metadata and controls
92 lines (73 loc) · 1.98 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import glob
import os
import frontmatter # pip install python-frontmatter
from collections import defaultdict
order = [
"Countries",
"Events",
"Groups",
"Companies",
"Locations",
"Technology",
"Politics",
"Other",
]
cats = defaultdict(lambda: defaultdict(list))
for md in glob.glob("md-src/*.md"):
name = os.path.basename(md)
if name in ("index.md", "contributions.md", "search.md"):
continue
meta = frontmatter.load(md)
title = meta["title"]
cat = meta.get("tag", "Other")
if "." in cat:
main, sub = cat.split(".")
else:
main, sub = cat, None
complete = meta.get("complete", False)
cats[main][sub].append((title, name, complete))
print("---")
print('title: "Aetherworld"')
print("---\n")
print("""<style>
.cols {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(10em, 1fr));
gap: 2em;
row-gap: 0.5em;
margin: 0;
padding: 0
}
.col {
break-inside: avoid
}
h2 {
text-decoration: underline
}
h2,
h3 {
margin-bottom: 0
}
</style>
""")
print(
"Pages marked with ▲ are relatively complete and good places to start exploring. For a general overview of aetherworld, check out the [[introduction]]. \n"
)
def printCat(main):
print(f"::: {{.col}}\n## {main}")
for page, link, complete in sorted(cats[main][None]):
mark = ' <span class="complete"></span>' if complete else ""
print(f"- [[{page}|{link}]]{mark}")
for sub in sorted(s for s in cats[main] if s is not None):
print(f"\n### {sub}")
for page, link, complete in sorted(cats[main][sub]):
mark = ' <span class="complete"></span>' if complete else ""
print(f"- [[{page}|{link}]]{mark}")
print(":::\n")
print("::: {.cols}")
for main in order:
printCat(main)
for main in sorted(cats, key=str.lower):
if main not in order:
printCat(main)
print("\n:::")