Add breadcrumbs
This commit is contained in:
parent
720557d2a6
commit
43bbb7fbcd
4 changed files with 23 additions and 0 deletions
|
@ -51,4 +51,8 @@ section.hero {
|
|||
.column {
|
||||
padding-bottom: unset;
|
||||
}
|
||||
|
||||
nav.breadcrumb {
|
||||
margin-bottom: 0.5rem !important;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
12
website/common/templates/common/breadcrumbs.html
Normal file
12
website/common/templates/common/breadcrumbs.html
Normal 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 %}
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue