feat: category neighbours on the post page

The post page links previous_in_category and next_in_category (the
Journal's opt-in scored related mode) as server-rendered links with the
title in the anchor text when the Journal answers one, else the
site-wide previous_post and next_post (postNeighbours). Types, a fixture
post and expectation lines for both cases.
This commit is contained in:
Jakub Zych
2026-11-04 14:15:22 +01:00
parent ed50826bf7
commit adcea4d538
7 changed files with 70 additions and 12 deletions

View File

@@ -134,3 +134,10 @@
200 /blog/tag/release count=application/ld+json:1 contains=ItemList
200 /blog/author/jane-doe count=application/ld+json:1 contains=ItemList
200 /blog/hello-acme notcontains=ItemList
# Category neighbours (the Journal's opt-in related_mode scored): the post
# answer's previous_in_category and next_in_category render as server-side
# links instead of the site-wide neighbours; without them the site-wide
# previous_post and next_post stay.
200 /blog/heading-on contains=href="/blog/acme-note-04" class="journal-post__previous" rel="prev"><span>Previous post</span> Acme Note 04</a> contains=href="/blog/acme-note-06" class="journal-post__next" rel="next"><span>Next post</span> Acme Note 06</a>
200 /blog/heading-off contains=href="/blog/heading-on" class="journal-post__next" rel="next"><span>Next post</span> Heading On Sample</a> notcontains=journal-post__previous

View File

@@ -497,7 +497,17 @@
"translations": {},
"created_at": "2025-12-20T09:00:00+00:00",
"updated_at": "2025-12-20T09:00:00+00:00",
"content_h1_to_h2": true
"content_h1_to_h2": true,
"previous_in_category": {
"id": 4,
"title": "Acme Note 04",
"slug": "acme-note-04"
},
"next_in_category": {
"id": 6,
"title": "Acme Note 06",
"slug": "acme-note-06"
}
},
{
"id": 16,