From 2132cfd48de5da2e6ca0785e28bda1894b2a2884 Mon Sep 17 00:00:00 2001 From: SG Date: Wed, 11 Jun 2025 19:13:43 +0300 Subject: [PATCH] updates --- classes.py | 12 ++++++++++-- templates/index.html | 22 +++++++++++++++++++++- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/classes.py b/classes.py index a4a973b..7be5b1d 100644 --- a/classes.py +++ b/classes.py @@ -7,7 +7,7 @@ import frontmatter from pathlib import Path from logger import logger from config import Config -from jinja_env import env, content_item_template, index_template, categories_index_template +from jinja_env import env, content_item_template, index_template class ContentItem: def render_content(self): @@ -124,7 +124,7 @@ class Site: self.output_dir.mkdir() # Create public subdirs - subdirs = [self.images_dir, self.css_dir, self.js_dir, self.content_dir] + subdirs = [self.images_dir, self.css_dir, self.js_dir, self.content_dir, "categories"] for subdir in subdirs: subdir = self.output_dir / subdir subdir.mkdir(parents=True, exist_ok=True) @@ -147,6 +147,14 @@ class Site: 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: + 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)) + + # Render the about file about_content = ContentItem(Path('static/about.md')) about_content.parse_content() diff --git a/templates/index.html b/templates/index.html index cf0a60f..f1b585d 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,14 +1,19 @@ {% extends "default.html" %} +{% block head_includes %} + +{% endblock %} + {% block menu_links %} Home + Categories About {% endblock %} {% block content %}
-
+