diff --git a/classes.py b/classes.py index 0514b4b..2b30715 100644 --- a/classes.py +++ b/classes.py @@ -142,27 +142,29 @@ class Site: # Build categories map self.map_categories() - # Parse the content files + # Render the content files logger.debug(f"Content items: {self.content_items}") for content_item in self.content_items: content_item.render_content(categories = self.categories) - # Render the index file - with (self.output_dir / "index.html").open("w", encoding="utf-8") as f: - f.write(index_template.render(page_title = Config.MAIN_PAGE_TITLE, content_items=self.content_items, categories = self.categories)) - - # Render the categories indices - for category in self.categories: - print(F"CREATING CATEGORY {category}.html") - category_index = Path(f"{self.output_dir}/categories/{category}.html") - category_items = [i for i in self.content_items if category in i.data.get("categories")] - with (category_index).open(mode="w", encoding="utf-8") as f: - f.write(index_template.render(page_title=category, content_items=category_items, categories = self.categories, parent_path = '../')) - # Render the about file about_content = ContentItem(Path('static/about.md')) about_content.parse_content() about_content.render_content(categories = self.categories) + # Render the index file + visible_content_items = [c for c in self.content_items if c.data.get("hidden") != True] + with (self.output_dir / "index.html").open("w", encoding="utf-8") as f: + f.write(index_template.render(page_title = Config.MAIN_PAGE_TITLE, content_items=visible_content_items, categories = self.categories)) + + # Render the categories indices + visible_content_items = [c for c in self.content_items if c.data.get("hidden") != True] + for category in self.categories: + print(F"CREATING CATEGORY {category}.html") + category_index = Path(f"{self.output_dir}/categories/{category}.html") + category_items = [i for i in visible_content_items if category in i.data.get("categories")] + with (category_index).open(mode="w", encoding="utf-8") as f: + f.write(index_template.render(page_title=category, content_items=category_items, categories = self.categories, parent_path = '../')) + logger.info(f"Created {len(self.content_items)} content items.") \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index 6a710d3..f91c3ef 100644 --- a/templates/index.html +++ b/templates/index.html @@ -16,7 +16,7 @@
{% if content_item.image_file %} - {{ content_item.title }} + {{ content_item.title }} {% else %} {{ content_item.title }} {% endif %}