diff options
author | 2021-03-24 14:14:43 +0800 | |
---|---|---|
committer | 2021-03-24 14:14:43 +0800 | |
commit | dbac69c7a58938fb24128a787971ea1bc1892110 (patch) | |
tree | 7926d90cf2c9954b6dcfdafdbe0677c30f7a8377 | |
parent | Refactor common HTML into a base template. (diff) |
Improve variable and key names for page utils.
-rw-r--r-- | pydis_site/apps/content/utils.py | 6 | ||||
-rw-r--r-- | pydis_site/apps/content/views/page_category.py | 2 | ||||
-rw-r--r-- | pydis_site/templates/content/listing.html | 2 | ||||
-rw-r--r-- | pydis_site/templates/content/page.html | 4 |
4 files changed, 7 insertions, 7 deletions
diff --git a/pydis_site/apps/content/utils.py b/pydis_site/apps/content/utils.py index 6cb15581..8cbcad91 100644 --- a/pydis_site/apps/content/utils.py +++ b/pydis_site/apps/content/utils.py @@ -25,8 +25,8 @@ def get_categories(path: Path) -> Dict[str, Dict]: return categories -def get_pages(path: Path) -> Dict[str, Dict]: - """Get all root or category page names and their metadata.""" +def get_category_pages(path: Path) -> Dict[str, Dict]: + """Get all page names and their metadata at a category path.""" pages = {} for item in path.iterdir(): @@ -56,4 +56,4 @@ def get_page(path: Path) -> Dict[str, Union[str, Dict]]: ] ) - return {"page": str(html), "metadata": html.metadata} + return {"content": str(html), "metadata": html.metadata} diff --git a/pydis_site/apps/content/views/page_category.py b/pydis_site/apps/content/views/page_category.py index 623c2596..0bef82d0 100644 --- a/pydis_site/apps/content/views/page_category.py +++ b/pydis_site/apps/content/views/page_category.py @@ -39,7 +39,7 @@ class PageOrCategoryView(TemplateView): context["category_info"] = category context["page_title"] = category["name"] context["page_description"] = category["description"] - context["content"] = utils.get_pages(self.full_location) + 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")) diff --git a/pydis_site/templates/content/listing.html b/pydis_site/templates/content/listing.html index 9271f3ab..6de306b0 100644 --- a/pydis_site/templates/content/listing.html +++ b/pydis_site/templates/content/listing.html @@ -13,7 +13,7 @@ <p class="is-italic">{{ data.description }}</p> </div> {% endfor %} - {% for page, data in content.items %} + {% for page, data in pages.items %} <div class="box" style="max-width: 800px;"> <span class="icon is-size-4 is-medium"> <i class="{{ data.icon_class|default:"fab" }} {{ data.icon|default:"fa-python" }} is-size-3 is-black has-icon-padding" aria-hidden="true"></i> diff --git a/pydis_site/templates/content/page.html b/pydis_site/templates/content/page.html index 2b366e50..5e820c26 100644 --- a/pydis_site/templates/content/page.html +++ b/pydis_site/templates/content/page.html @@ -12,7 +12,7 @@ {% if relevant_links|length > 0 %} <div class="columns is-variable is-8"> <div class="column is-two-thirds"> - {{ page.page|safe }} + {{ page.content|safe }} </div> <div class="column"> <div class="box"> @@ -26,6 +26,6 @@ </div> </div> {% else %} - <div>{{ page.page|safe }}</div> + <div>{{ page.content|safe }}</div> {% endif %} {% endblock %} |