1import json
2
3with open('json/cards.json') as f:
4 x = json.load(f)
5
6text = ""
7for i in x["cards"]:
8 text += f"""
9 <div class="card">
10 <h1>{i["name"]}</h1>
11 <p>{i["description"]}</p>
12 <div class="buttons">
13 <a href="{i["link"]}"><button class="button">{i["button_text"]}</button></a>
14 """
15 if i["tor"] != "#":
16 text += f'<a href="{i["tor"]}"><button class="tor">Tor</button></a>'
17
18 text += "</div></div>"
19
20with open('_site/index.html') as f:
21 y = f.read()
22
23y = y.replace('<!-- Static cards -->', text)
24with open('_site/index.html', 'w') as f:
25 f.write(y)