aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/apps/content/urls.py
diff options
context:
space:
mode:
authorGravatar Hassan Abouelela <[email protected]>2022-08-13 06:10:38 +0200
committerGravatar Hassan Abouelela <[email protected]>2022-08-13 06:10:38 +0200
commit42124deb7ea5f17bc6faf959baba8e951b567655 (patch)
treed485bbeecc278cff5fa24eba566d5a95a2b5cff0 /pydis_site/apps/content/urls.py
parentAdd Tags To Content Listings (diff)
Add Tag Page Template
Add a template for the tag page itself, and add a route to use it. Signed-off-by: Hassan Abouelela <[email protected]>
Diffstat (limited to 'pydis_site/apps/content/urls.py')
-rw-r--r--pydis_site/apps/content/urls.py21
1 files changed, 18 insertions, 3 deletions
diff --git a/pydis_site/apps/content/urls.py b/pydis_site/apps/content/urls.py
index f8496095..b4ffc07d 100644
--- a/pydis_site/apps/content/urls.py
+++ b/pydis_site/apps/content/urls.py
@@ -3,7 +3,7 @@ from pathlib import Path
from django_distill import distill_path
-from . import views
+from . import utils, views
app_name = "content"
@@ -29,18 +29,33 @@ def __get_all_files(root: Path, folder: typing.Optional[Path] = None) -> list[st
return results
-def get_all_pages() -> typing.Iterator[dict[str, str]]:
+DISTILL_RETURN = typing.Iterator[dict[str, str]]
+
+
+def get_all_pages() -> DISTILL_RETURN:
"""Yield a dict of all page categories."""
for location in __get_all_files(Path("pydis_site", "apps", "content", "resources")):
yield {"location": location}
+def get_all_tags() -> DISTILL_RETURN:
+ """Return all tag names in the repository in static builds."""
+ for tag in utils.get_tags_static():
+ yield {"name": tag.name}
+
+
urlpatterns = [
distill_path("", views.PageOrCategoryView.as_view(), name='pages'),
distill_path(
+ "tags/<str:name>/",
+ views.TagView.as_view(),
+ name="tag",
+ distill_func=get_all_tags
+ ),
+ distill_path(
"<path:location>/",
views.PageOrCategoryView.as_view(),
name='page_category',
distill_func=get_all_pages
- ),
+ )
]