From 43bbb7fbcd9632fb438b59a48fe738ef216c2fc8 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sun, 19 Jun 2022 16:56:47 +0100 Subject: [PATCH] Add breadcrumbs --- static/src/scss/_hero.scss | 4 ++++ website/common/models.py | 6 ++++++ website/common/templates/common/breadcrumbs.html | 12 ++++++++++++ website/common/templates/common/hero.html | 1 + 4 files changed, 23 insertions(+) create mode 100644 website/common/templates/common/breadcrumbs.html diff --git a/static/src/scss/_hero.scss b/static/src/scss/_hero.scss index 99f5a5c..4c21191 100644 --- a/static/src/scss/_hero.scss +++ b/static/src/scss/_hero.scss @@ -51,4 +51,8 @@ section.hero { .column { padding-bottom: unset; } + + nav.breadcrumb { + margin-bottom: 0.5rem !important; + } } diff --git a/website/common/models.py b/website/common/models.py index a38615e..1d9ef92 100644 --- a/website/common/models.py +++ b/website/common/models.py @@ -20,6 +20,12 @@ class BasePage(Page): def body_class(cls) -> str: return "page-" + cls._meta.db_table.replace("_", "-") + def get_parent_pages(self) -> models.QuerySet[Page]: + """ + Shim over the fact everything is in 1 tree + """ + return self.get_ancestors().reverse().exclude(depth__lte=2) + class BaseContentMixin(models.Model): subtitle = models.CharField(max_length=255, blank=True) diff --git a/website/common/templates/common/breadcrumbs.html b/website/common/templates/common/breadcrumbs.html new file mode 100644 index 0000000..2480c57 --- /dev/null +++ b/website/common/templates/common/breadcrumbs.html @@ -0,0 +1,12 @@ +{% load wagtailcore_tags %} + +{% if parents %} + +{% endif %} diff --git a/website/common/templates/common/hero.html b/website/common/templates/common/hero.html index 7791b16..c4af0f1 100644 --- a/website/common/templates/common/hero.html +++ b/website/common/templates/common/hero.html @@ -9,6 +9,7 @@
+ {% include "common/breadcrumbs.html" with parents=page.get_parent_pages %}

{{ page.title }}

{% if page.subtitle %}

{{ page.subtitle }}