From 48f64bf3d4acf0b7330f2f6d9b81f004ed9d6ee0 Mon Sep 17 00:00:00 2001 From: Akbar Rahman Date: Tue, 2 Jan 2024 04:02:48 +0000 Subject: [PATCH] render index pages properly --- gronk.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/gronk.py b/gronk.py index 2dc84c4..80dfcdc 100755 --- a/gronk.py +++ b/gronk.py @@ -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)