From f4191b274619a75f9d550ce2a899f0a87e8a3cc4 Mon Sep 17 00:00:00 2001 From: Vinta Chen Date: Mon, 26 Oct 2026 10:55:51 +0800 Subject: [PATCH] refactor: extract shared projects table macro Co-Authored-By: Claude --- website/templates/_projects_table.html | 74 ++++++++++++++++++++++++++ website/templates/category.html | 74 ++------------------------ website/templates/index.html | 74 ++------------------------ 3 files changed, 80 insertions(+), 142 deletions(-) create mode 100644 website/templates/_projects_table.html diff --git a/website/templates/_projects_table.html b/website/templates/_projects_table.html new file mode 100644 index 00000000..193000e3 --- /dev/null +++ b/website/templates/_projects_table.html @@ -0,0 +1,74 @@ +{% macro projects_table(count, scope, editorial=false) %} +
+

Search and filter

+
+ + +
+
+ +

Results

+
+ + + + + + + + + + + + + +{{ caller() }} + +
Row number + + + + + + + + Tags + +
+
+ + +{% endmacro %} diff --git a/website/templates/category.html b/website/templates/category.html index cdadd21f..10fa0bd5 100644 --- a/website/templates/category.html +++ b/website/templates/category.html @@ -1,4 +1,5 @@ {% extends "base.html" %} +{% from "_projects_table.html" import projects_table %} {% block title %}{{ category_title }}{% endblock %} {% block description %}{{ category_description }}{% endblock %} {% block canonical_url %}{{ category_url }}{% endblock %} @@ -216,66 +217,7 @@

-
-

Search and filter

-
- - -
-
- -

Results

-
- - - - - - - - - - - - - + {% call projects_table(entries | length, "in " ~ category.name, entry_groups) %} {% if entry_groups %} {% set row = namespace(index=0) %} {% for group in entry_groups %} @@ -302,17 +244,7 @@ {{ entry_rows(entry, loop.index) }} {% endfor %} {% endif %} - -
Row number - - - - - - - - Tags - -
-
- - + {% endcall %} {% if guide_html %} diff --git a/website/templates/index.html b/website/templates/index.html index b6b1e578..8d0a4385 100644 --- a/website/templates/index.html +++ b/website/templates/index.html @@ -1,4 +1,5 @@ {% extends "base.html" %} +{% from "_projects_table.html" import projects_table %} {% block extra_head %} {% endblock %} @@ -68,66 +69,7 @@

-
-

Search and filter

-
- - -
-
- -

Results

-
- - - - - - - - - - - - - + {% call projects_table(entries | length, "across " ~ total_categories ~ " categories") %} {% for entry in entries %} {% endfor %} - -
Row number - - - - - - - - Tags - -
-
- - + {% endcall %} {% include "_final_cta.html" +%}