aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/apps/content/views
diff options
context:
space:
mode:
authorGravatar kosayoda <[email protected]>2021-03-24 19:55:16 +0800
committerGravatar kosayoda <[email protected]>2021-03-24 19:55:16 +0800
commit6ccec0d866c44cd7f9789a396ef6ec6cd2cd5df8 (patch)
tree15ffa3caff8b0a625028d1085a3246683c630d07 /pydis_site/apps/content/views
parentSimplify pathlib code and specify file encoding. (diff)
Replace `markdown2` with `markdown` and `python-frontmatter`.
This allows us to properly escape codeblocks within markdown, permalink to headers on a page, and decouples getting metadata from a file and getting generated HTML from the Markdown content.
Diffstat (limited to 'pydis_site/apps/content/views')
-rw-r--r--pydis_site/apps/content/views/page_category.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/pydis_site/apps/content/views/page_category.py b/pydis_site/apps/content/views/page_category.py
index 91aed7f0..4a2ed2d6 100644
--- a/pydis_site/apps/content/views/page_category.py
+++ b/pydis_site/apps/content/views/page_category.py
@@ -35,18 +35,19 @@ class PageOrCategoryView(TemplateView):
if self.full_location.is_dir():
context["categories"] = utils.get_categories(self.full_location)
+ context["pages"] = utils.get_category_pages(self.full_location)
+
category = utils.get_category(self.full_location)
- context["category_info"] = category
context["page_title"] = category["name"]
context["page_description"] = category["description"]
- context["pages"] = utils.get_category_pages(self.full_location)
+
context["path"] = f"{self.location}/" # Add trailing slash here to simplify template
elif self.full_location.with_suffix(".md").is_file():
- page_result = utils.get_page(self.full_location.with_suffix(".md"))
- context["page"] = page_result
- context["page_title"] = page_result["metadata"]["title"]
- context["page_description"] = page_result["metadata"]["description"]
- context["relevant_links"] = page_result["metadata"].get("relevant_links", {})
+ page, metadata = utils.get_page(self.full_location.with_suffix(".md"))
+ context["page"] = page
+ context["page_title"] = metadata["title"]
+ context["page_description"] = metadata["description"]
+ context["relevant_links"] = metadata.get("relevant_links", {})
else:
raise Http404