Add breadcrumbs

This commit is contained in:
Jake Howard 2022-06-19 16:56:47 +01:00
parent 720557d2a6
commit 43bbb7fbcd
Signed by: jake
GPG key ID: 57AFB45680EDD477
4 changed files with 23 additions and 0 deletions

View file

@ -51,4 +51,8 @@ section.hero {
.column {
padding-bottom: unset;
}
nav.breadcrumb {
margin-bottom: 0.5rem !important;
}
}

View file

@ -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)

View file

@ -0,0 +1,12 @@
{% load wagtailcore_tags %}
{% if parents %}
<nav class="breadcrumb" aria-label="breadcrumbs">
<ul>
{% for parent in parents %}
<li><a href="{% pageurl parent %}">{{ parent.title }}</a></li>
{% endfor %}
<li class="is-active"><a href="{% pageurl page %}" aria-current="page">{{ page.title }}</a></li>
</ul>
</nav>
{% endif %}

View file

@ -9,6 +9,7 @@
<div class="hero-body">
<div class="columns">
<div class="column">
{% include "common/breadcrumbs.html" with parents=page.get_parent_pages %}
<h1 class="title is-1">{{ page.title }}</h1>
{% if page.subtitle %}
<h2 class="subtitle">{{ page.subtitle }}</h2>