-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
35 lines (28 loc) · 1.11 KB
/
main.py
File metadata and controls
35 lines (28 loc) · 1.11 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
import md2html
import yaml
import logging
def main():
logging.basicConfig(level=logging.INFO, format="%(levelname)s: %(message)s")
logger = logging.getLogger(__name__)
# Open and parse site config file
with open('site-config.yaml', encoding="utf-8") as config_file:
site_config = yaml.safe_load(config_file.read())
# Create navigation data
navigation = [(page['id'], page['link_text'], page['html_file']) for page in site_config]
# Iterate each page - process and save
for page in site_config:
if not page['generate']:
continue
md_path = 'md/' + page['md_file']
template_path = 'templates/main.html'
title = page['title']
document = md2html.Document(md_path, template_path,
title=title, id=page['id'],
html_file=page['html_file'],
url="https://python.ostrawebb.se/"
)
document.insert_main_nav(navigation)
document.save_html('public_html/' + page['html_file'])
logger.info(f"Generated {page['title']} as {page['html_file']}")
if __name__ == '__main__':
main()