generated from TechnicJelle/SimpleCustomSSGTemplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ssg.py
30 lines (22 loc) · 1.13 KB
/
ssg.py
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
from shutil import copytree
import markdown
# official_extensions = ['extra', 'admonition', 'meta', 'nl2br', 'smarty']
# thirdparty_extensions = ['markdown_sub_sup', 'markdown_del_ins', 'markdown_mark', 'markdown_gfm_admonition', ~~'mdx_outline',~~ 'mdx_truly_sane_lists', 'mdx_wikilink_plus', ~~'mdx_tableau'~~]
# all_extensions = [official_extensions + thirdparty_extensions]
all_extensions = ['extra', 'admonition', 'meta', 'nl2br', 'smarty', 'markdown_sub_sup', 'markdown_del_ins', 'markdown_mark', 'markdown_gfm_admonition', 'mdx_truly_sane_lists', 'mdx_wikilink_plus']
# Copy static files to the build directory
copytree("static/", "build/", dirs_exist_ok=True)
# Load the template and content
template: str
content: str
with open("templates/index.html") as file:
template = file.read()
with open("content/index.md") as file:
content = file.read()
# Convert the markdown to HTML
html = markdown.markdown(content, extensions=all_extensions)
# Insert the HTML content into the template
output: str = template.replace("{{content}}", html)
# Write the output to the build directory
with open("build/index.html", "w") as file:
file.write(output)