render index pages properly

This commit is contained in:
Akbar Rahman 2024-01-02 04:02:48 +00:00
parent 4e5bd41953
commit 48f64bf3d4
Signed by: alvierahman90
GPG Key ID: 6217899F07CA2BDF

View File

@ -462,13 +462,28 @@ def main(args):
root_properties = FILEMAP.get(root)
root_properties['dst_path']['raw'].mkdir(parents=True, exist_ok=True)
#pprint.pprint(root_properties)
html = JINJA_TEMPLATE_INDEX.render(**root_properties)
with open(root_properties['dst_path']['raw'].joinpath('index.html'), 'w+', encoding='utf-8') as file_pointer:
file_pointer.write(html)
pprint.pprint(root_properties)
html = JINJA_TEMPLATE_INDEX.render(
gronk_commit=GRONK_COMMIT,
title=root_properties.get('title', ''),
content=root_properties.get('content', ''),
content_after_search=root_properties['content_after_search'],
automatic_index=root_properties['automatic_index'],
search_bar=root_properties['search_bar'],
index_entries=[{
'title': entry.get('title', ''),
'is_dir': entry.get('is_dir', False),
'path': str(entry.get('path', Path(''))),
} for entry in root_properties.get('index_entries', '')],
)
root_properties['dst_path']['raw'].joinpath('index.html').write_text(
html)
# render each file
for file in files:
# don't render index.md as index as it is used for directory
if file == "index.md":
continue
render_file(root.joinpath(file))
process_home_index(args)