diff options
author | 2021-04-01 19:11:28 +0800 | |
---|---|---|
committer | 2021-04-01 19:11:28 +0800 | |
commit | bbb6fc242a4eb10551a8549c400f3db88658fce1 (patch) | |
tree | 24624910bcf33e1b16033885e619a4d629ea953f /pydis_site/apps/content/views | |
parent | Document defining a table of contents for a page. (diff) |
Add a dropdown menu listing direct children.
This only shows when the page is also a category, since regular pages
have no children and regular categories already list their children.
Diffstat (limited to 'pydis_site/apps/content/views')
-rw-r--r-- | pydis_site/apps/content/views/page_category.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/pydis_site/apps/content/views/page_category.py b/pydis_site/apps/content/views/page_category.py index 8783e33f..bb2c07cc 100644 --- a/pydis_site/apps/content/views/page_category.py +++ b/pydis_site/apps/content/views/page_category.py @@ -47,6 +47,13 @@ class PageOrCategoryView(TemplateView): else: raise Http404 + # Add subarticle information for dropdown menu if the page is also a category + if self.page_path.is_file() and self.category_path.is_dir(): + context["subarticles"] = [ + path.stem for path in self.category_path.iterdir() + if path.suffix != ".yml" + ] + context["breadcrumb_items"] = [ { "name": utils.get_category(settings.PAGES_PATH / location)["title"], |