Add breadcrumbs to search results

This commit is contained in:
Jake Howard 2023-12-25 22:22:10 +00:00
parent b13fe49664
commit 3c66267b79
Signed by: jake
GPG key ID: 57AFB45680EDD477
4 changed files with 10 additions and 3 deletions

View file

@ -42,6 +42,10 @@
.columns { .columns {
width: 100%; width: 100%;
} }
nav.breadcrumb {
margin-bottom: 0;
}
} }
.page-blogpostlistpage { .page-blogpostlistpage {

View file

@ -1,6 +1,6 @@
{% load wagtailcore_tags cache util_tags %} {% load wagtailcore_tags cache util_tags %}
{% cache FRAGMENT_CACHE_TTL|jitter:FRAGMENT_CACHE_TTL_JITTER "listing-item" page.id request.is_preview %} {% cache FRAGMENT_CACHE_TTL|jitter:FRAGMENT_CACHE_TTL_JITTER "listing-item" page.id request.is_preview breadcrumbs %}
<article class="media listing-item"> <article class="media listing-item">
<div class="columns"> <div class="columns">
<figure class="media-left column is-3 image-column"> <figure class="media-left column is-3 image-column">
@ -12,6 +12,9 @@
</figure> </figure>
<div class="media-content column"> <div class="media-content column">
<div> <div>
{% if breadcrumbs %}
{% include "common/breadcrumbs.html" with parents=page.get_parent_pages %}
{% endif %}
<h2 class="title is-3"> <h2 class="title is-3">
<a href="{% pageurl page %}">{{ page.title }}</a> <a href="{% pageurl page %}">{{ page.title }}</a>
</h2> </h2>

View file

@ -1,7 +1,7 @@
{% load wagtailadmin_tags %} {% load wagtailadmin_tags %}
{% for page in results %} {% for page in results %}
{% include "common/listing-item.html" %} {% include "common/listing-item.html" with breadcrumbs=True %}
{% endfor %} {% endfor %}
{% if not results and page_num == 1 %} {% if not results and page_num == 1 %}

View file

@ -55,7 +55,7 @@ class SearchPageResultsTestCase(TestCase):
cls.url = cls.page.url + cls.page.reverse_subpage("results") cls.url = cls.page.url + cls.page.reverse_subpage("results")
def test_returns_results(self) -> None: def test_returns_results(self) -> None:
with self.assertNumQueries(12): with self.assertNumQueries(24):
response = self.client.get(self.url, {"q": "post"}, HTTP_HX_REQUEST="true") response = self.client.get(self.url, {"q": "post"}, HTTP_HX_REQUEST="true")
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)