Add homepage tag discovery matrix
Deploy production / deploy (push) Successful in 21s

This commit is contained in:
2026-08-23 16:51:54 -07:00
parent fe6025fa63
commit 623686590c
6 changed files with 244 additions and 5 deletions
+36 -3
View File
@@ -5,10 +5,14 @@ import unittest
class HomeTemplateTests(unittest.TestCase):
def test_recent_activity_adds_only_latest_devlog_from_each_project(self) -> None:
def setUp(self) -> None:
site_root = Path(__file__).resolve().parents[1]
template = (site_root / "templates" / "home.html").read_text(encoding="utf-8")
recent_activity = template.split(
self.template = (site_root / "templates" / "home.html").read_text(
encoding="utf-8"
)
def test_recent_activity_adds_only_latest_devlog_from_each_project(self) -> None:
recent_activity = self.template.split(
'<section class="homepage-panel featured-projects-panel"', 1
)[0]
@@ -19,6 +23,35 @@ class HomeTemplateTests(unittest.TestCase):
self.assertIn("entries.append(latest_devlog_entry)", recent_activity)
self.assertNotIn("for entry in devlog.children", recent_activity)
def test_tag_matrix_is_last_homepage_section_and_uses_canonical_tags(self) -> None:
matrix_position = self.template.index("{% set tracked_tags")
featured_position = self.template.index(
'class="homepage-panel featured-projects-panel"'
)
self.assertGreater(matrix_position, featured_position)
self.assertIn("site.get('/tags').children", self.template[matrix_position:])
self.assertIn('href="{{ tag|url }}"', self.template[matrix_position:])
self.assertNotIn("'/tags/' ~ tag", self.template[matrix_position:])
def test_tag_matrix_counts_all_discovery_content_and_caps_weighting(self) -> None:
matrix = self.template.split('class="homepage-tag-section"', 1)[1]
self.assertIn("['projects', 'blog', 'articles']", matrix)
self.assertIn("entry.topic_tag_slugs", matrix)
self.assertIn("usage.count >= 8", matrix)
self.assertIn("usage.count >= 4", matrix)
self.assertIn("usage.count >= 2", matrix)
self.assertIn("tag-matrix-level-{{ weight }}", matrix)
def test_tag_matrix_keeps_links_semantic_and_summary_optional(self) -> None:
matrix = self.template.split('class="homepage-tag-section"', 1)[1]
self.assertIn('aria-label="Explore content by topic"', matrix)
self.assertIn('rel="tag"', matrix)
self.assertIn("data-tag-summary", matrix)
self.assertIn("published {% if usage.count == 1 %}entry", matrix)
if __name__ == "__main__":
unittest.main()