Add "View all" button for similar content

This commit is contained in:
Jake Howard 2023-06-21 11:50:43 +01:00
parent f3ee847b28
commit cbd1eb027b
Signed by: jake
GPG Key ID: 57AFB45680EDD477
4 changed files with 14 additions and 2 deletions

View File

@ -4,10 +4,14 @@ section#similar-content {
align-items: center;
margin-top: 2rem;
h2 {
.subtitle {
color: inherit;
}
.view-all {
margin: $block-spacing 0;
}
.media {
@include desktop {
transform: scale(85%);

View File

@ -68,6 +68,10 @@ class BlogPostPage(BaseContentPage):
def tag_list_page_url(self) -> Optional[str]:
return SingletonPageCache.get_url(BlogPostTagListPage)
@cached_property
def blog_post_list_page_url(self) -> Optional[str]:
return SingletonPageCache.get_url(BlogPostListPage)
def get_similar_posts(self) -> models.QuerySet:
try:
listing_pages = BlogPostListPage.objects.get().get_listing_pages()

View File

@ -15,6 +15,10 @@
{% include "common/listing-item.html" %}
{% endblock %}
{% endfor %}
<p class="subtitle view-all">
<a href="{{ page.blog_post_list_page_url }}">View all &rarr;</a>
</p>
</section>
{% endcache %}
{% endif %}

View File

@ -17,7 +17,7 @@ class BlogPostPageTestCase(TestCase):
self.assertEqual(response.status_code, 200)
def test_queries(self) -> None:
with self.assertNumQueries(45):
with self.assertNumQueries(47):
self.client.get(self.page.url)