commit f12b922bd116d1a781cc35cd67ebdf8a8a111763
parent 16f9dc02fc452395bc283b5dbbc68c237a583848
Author: Silas Brack <silasbrack@gmail.com>
Date: Thu, 2 Oct 2025 17:21:10 +0200
fix: load more when filtering category, change formatting
Diffstat:
3 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/simple_web_app/app.py b/src/simple_web_app/app.py
@@ -113,7 +113,7 @@ async def show_home_page(request: Request):
elapsed = time.time() - t0
logger.info({"event": "load_page", "page": "/home", "time_s": elapsed})
- context = {"news": news, "categories": all_categories, "page": page, "current_time": current_time}
+ context = {"news": news, "categories": all_categories, "page": page, "current_time": current_time, "category_id": category_id}
if is_htmx_request(request):
context = context | {"oob": True}
template_name = "oob_swap.html" if is_htmx_request(request) else "index.html"
diff --git a/src/simple_web_app/templates/load_more.html b/src/simple_web_app/templates/load_more.html
@@ -1 +1 @@
-<button id="load-more-btn" {% if oob %}hx-swap-oob="true"{% endif %} hx-target="#news-cards" hx-swap="beforeend" hx-get="/?page={{ page + 1 }}¤t_time={{ current_time }}" class="secondary">Load more</button>
+<button id="load-more-btn" {% if oob %}hx-swap-oob="true"{% endif %} hx-target="#news-cards" hx-swap="beforeend" hx-get="/?category-id={{ category_id }}&page={{ page + 1 }}¤t_time={{ current_time }}" class="secondary">Load more</button>
diff --git a/src/simple_web_app/templates/news_card.html b/src/simple_web_app/templates/news_card.html
@@ -1,8 +1,10 @@
<article>
<header>
+ <nav><ul>
{% for category in new.categories %}
- <small><a style="cursor: pointer;" hx-get="/?category-id={{ category.id }}" hx-target="#news-cards">{{ category.name }}</a></small>
+ <li><div style="cursor: pointer;" hx-get="/?category-id={{ category.id }}" hx-target="#news-cards"><small>{{ category.name }}</small></div></small></li>
{% endfor %}
+ </ul></nav>
</header>
<details>
<summary>