From 624e87d15ccfbe4ba2410dcaab0b4fb494b664e5 Mon Sep 17 00:00:00 2001 From: kosayoda Date: Sat, 27 Mar 2021 12:42:07 +0800 Subject: Improve content page and listing metadata keys. Make category `title` consistent with page `title`. Simplify `icon` key, since there is no benefit to defining the icon class and the icon separately. Allow overriding the `icon` for category entries just like page entries. --- pydis_site/apps/content/resources/_info.yml | 2 +- pydis_site/apps/content/resources/guides/_info.yml | 2 +- .../apps/content/resources/guides/pydis-guides/_info.yml | 2 +- .../guides/pydis-guides/how-to-contribute-a-page.md | 12 +++++------- pydis_site/apps/content/views/page_category.py | 5 +++-- pydis_site/templates/content/listing.html | 6 +++--- 6 files changed, 14 insertions(+), 15 deletions(-) (limited to 'pydis_site') diff --git a/pydis_site/apps/content/resources/_info.yml b/pydis_site/apps/content/resources/_info.yml index 583cab18..6553dcc6 100644 --- a/pydis_site/apps/content/resources/_info.yml +++ b/pydis_site/apps/content/resources/_info.yml @@ -1,2 +1,2 @@ -name: Pages +title: Pages description: Guides, articles, and pages hosted on the site. diff --git a/pydis_site/apps/content/resources/guides/_info.yml b/pydis_site/apps/content/resources/guides/_info.yml index 59c60a7b..2f65eaf9 100644 --- a/pydis_site/apps/content/resources/guides/_info.yml +++ b/pydis_site/apps/content/resources/guides/_info.yml @@ -1,2 +1,2 @@ -name: Guides +title: Guides description: Made by us, for you. diff --git a/pydis_site/apps/content/resources/guides/pydis-guides/_info.yml b/pydis_site/apps/content/resources/guides/pydis-guides/_info.yml index 7c9a2225..c126a68a 100644 --- a/pydis_site/apps/content/resources/guides/pydis-guides/_info.yml +++ b/pydis_site/apps/content/resources/guides/pydis-guides/_info.yml @@ -1,2 +1,2 @@ -name: Python Discord Guides +title: Python Discord Guides description: Guides related to the Python Discord server and community. diff --git a/pydis_site/apps/content/resources/guides/pydis-guides/how-to-contribute-a-page.md b/pydis_site/apps/content/resources/guides/pydis-guides/how-to-contribute-a-page.md index f258ef74..51486bfe 100644 --- a/pydis_site/apps/content/resources/guides/pydis-guides/how-to-contribute-a-page.md +++ b/pydis_site/apps/content/resources/guides/pydis-guides/how-to-contribute-a-page.md @@ -1,8 +1,7 @@ --- title: How to Contribute a Page description: Learn how to write and publish a page to this website. -icon_class: fas -icon: fa-info +icon: fas fa-info relevant_links: Contributing to Site: https://pythondiscord.com/pages/contributing/site/ Using Git: https://pythondiscord.com/pages/contributing/working-with-git/ @@ -27,8 +26,9 @@ For example, the file `pydis_site/apps/content/resources/hello-world.md` will re Nested folders represent page categories on the website. Each folder under the root folder must include a `_info.yml` file with the following: ```yml -name: Category name +title: Category name description: Category description +icon: fas fa-folder # Optional ``` All the markdown files in this folder will then be under this category. @@ -44,8 +44,7 @@ The metadata is written in YAML, and should be enclosed in triple dashes `---` * --- title: How to Contribute a Page description: Learn how to write and publish a page to this website. -icon_class: fas -icon: fa-info +icon: fas fa-info relevant_links: Contributing to Site: https://pythondiscord.com/pages/contributing/site/ Using Git: https://pythondiscord.com/pages/contributing/working-with-git/ @@ -59,8 +58,7 @@ Pages, which include guides, articles, and other static content,... - **description:** Short, 1-2 line description of the page's content. ### Optional Fields -- **icon_class:** Favicon class for the category entry for the page. Default: `fab` -- **icon:** Favicon for the category entry for the page. Default: `fa-python` +- **icon:** Icon for the category entry for the page. Default: `fab fa-python` - **relevant_links:** A YAML dictionary containing `text:link` pairs. See the example above. ## Extended Markdown diff --git a/pydis_site/apps/content/views/page_category.py b/pydis_site/apps/content/views/page_category.py index eec4e7e5..723c5ad0 100644 --- a/pydis_site/apps/content/views/page_category.py +++ b/pydis_site/apps/content/views/page_category.py @@ -38,8 +38,9 @@ class PageOrCategoryView(TemplateView): context["pages"] = utils.get_category_pages(self.full_location) category = utils.get_category(self.full_location) - context["page_title"] = category["name"] + context["page_title"] = category["title"] context["page_description"] = category["description"] + context["icon"] = category.get("icon") context["path"] = f"{self.location}/" # Add trailing slash here to simplify template elif self.full_location.with_suffix(".md").is_file(): @@ -53,7 +54,7 @@ class PageOrCategoryView(TemplateView): context["breadcrumb_items"] = [ { - "name": utils.get_category(settings.PAGES_PATH / location)["name"], + "name": utils.get_category(settings.PAGES_PATH / location)["title"], "path": str(location) } for location in reversed(self.location.parents) ] diff --git a/pydis_site/templates/content/listing.html b/pydis_site/templates/content/listing.html index 6de306b0..ef0ef919 100644 --- a/pydis_site/templates/content/listing.html +++ b/pydis_site/templates/content/listing.html @@ -4,11 +4,11 @@ {% for category, data in categories.items %}
- + - {{ data.name }} + {{ data.title }}

{{ data.description }}

@@ -16,7 +16,7 @@ {% for page, data in pages.items %}
- + {{ data.title }} -- cgit v1.2.3