feat: pagination component and composable

- <SeoPagination> (UI-SPEC L2): previous and next (left out at the
  ends), page 1, the last page and five pages around the current one with
  gap items; nothing when last <= 1; props current, last, labels,
  classPrefix, locale
- usePagination(): hrefs in the CMS form (resolve answer, then site
  answer, then seo.pagination), other query parameters kept, page 1
  unnumbered, <link rel=prev/next> in the head
- the CMS head fills %pages% in the title and description once the
  listing's page count is known (seoFillPages)
- seoPaginationWindow, seoPageHref, seoPageNumber; L2 default styles
This commit is contained in:
Jakub Zych
2026-11-04 11:59:51 +01:00
parent ebb0c8084e
commit f2d13d6264
12 changed files with 459 additions and 4 deletions

View File

@@ -82,7 +82,7 @@ noreport /stary
# The route report at server start: the static paths with the token, not
# the signed-in page, the page with a noindex seo.robots or the declared
# noindex route. The build matches the site answer: no drift warning.
routereport 1 has=/ has=/plain has=/about lacks=/konto lacks=/szkic lacks=/prywatne
routereport 1 has=/ has=/blog has=/plain has=/about lacks=/konto lacks=/szkic lacks=/prywatne
log [vue-seo-layer] drift::0
# L1 breadcrumbs: a layout instance (app.vue) and a page instance render
@@ -91,3 +91,14 @@ log [vue-seo-layer] drift::0
200 /blog/lwia-grzywa count=<nav class="seo-breadcrumbs":1 contains=<a class="seo-breadcrumbs__link" href="/">Start</a> contains=<span class="seo-breadcrumbs__current" aria-current="page">Lwia grzywa</span> count=aria-current="page":1
200 / count=seo-breadcrumbs:0
200 /plain count=seo-breadcrumbs:0
# L2 pagination: numbered links in the CMS form, page 1 unnumbered, five
# pages around the current one plus the first and the last with two gaps,
# rel prev/next anchors and head links, and %pages% filled in the CMS title
# and description (the payload keeps the raw answer); one page renders
# none. aria-current: the current page and the breadcrumbs' last item.
200 /blog?page=5 count=<nav class="seo-pagination":1 contains=<a class="seo-pagination__prev" href="/blog?page=4" rel="prev"> contains=<a class="seo-pagination__next" href="/blog?page=6" rel="next"> contains=<span class="seo-pagination__current" aria-current="page">5</span> count=aria-current="page":2
200 /blog?page=5 contains=<a href="/blog" aria-label="Strona 1">1</a> contains=<a href="/blog?page=14" aria-label="Strona 14">14</a> count=seo-pagination__gap:2
200 /blog?page=5 contains=<link rel="prev" href="/blog?page=4" contains=<link rel="next" href="/blog?page=6" contains=<title>Blog – strona 5 z 14 | Example</title> contains=content="Wpisy o grzybach, strona 5 z 14" notcontains=z %pages% |</title> notcontains=content="Wpisy o grzybach, strona 5 z %pages%"
200 /blog?page=14&sort=new contains=<a class="seo-pagination__prev" href="/blog?sort=new&amp;page=13" rel="prev"> count=seo-pagination__next:0 count=rel="next":0
200 /blog?pages=1 count=seo-pagination:0 count=rel="prev":0

View File

@@ -179,5 +179,96 @@
"path": "/blog/lwia-grzywa"
}
]
},
"/blog": {
"action": "ok",
"status": 200,
"url": "https://example.test/blog",
"locale": "pl",
"staging": false,
"seo": {
"title": "Blog | Example",
"description": "Wpisy o grzybach",
"canonical": "https://example.test/blog",
"robots": "index, follow",
"x_robots_tag": "",
"og": {
"title": "Blog | Example",
"description": "Wpisy o grzybach",
"image": "",
"url": "https://example.test/blog",
"locale": "pl_PL",
"locale_alternates": []
},
"twitter": {
"card": "summary",
"site": ""
},
"verification": []
},
"html_lang": "pl",
"alternates": [],
"jsonld": null,
"breadcrumbs": [
{
"name": "Start",
"url": "https://example.test/",
"path": "/"
},
{
"name": "Blog",
"url": "https://example.test/blog",
"path": "/blog"
}
]
},
"/blog?page=5": {
"action": "ok",
"status": 200,
"url": "https://example.test/blog?page=5",
"locale": "pl",
"staging": false,
"seo": {
"title": "Blog – strona 5 z %pages% | Example",
"description": "Wpisy o grzybach, strona 5 z %pages%",
"canonical": "https://example.test/blog?page=5",
"robots": "index, follow",
"x_robots_tag": "",
"og": {
"title": "Blog – strona 5 z %pages% | Example",
"description": "Wpisy o grzybach, strona 5 z %pages%",
"image": "",
"url": "https://example.test/blog?page=5",
"locale": "pl_PL",
"locale_alternates": []
},
"twitter": {
"card": "summary",
"site": ""
},
"verification": []
},
"html_lang": "pl",
"alternates": [],
"jsonld": null,
"breadcrumbs": [
{
"name": "Start",
"url": "https://example.test/",
"path": "/"
},
{
"name": "Blog",
"url": "https://example.test/blog",
"path": "/blog"
}
],
"pagination": {
"form": "query",
"param": "page",
"segment": "",
"page": 5,
"invalid": false
}
}
}