fix: path-form listing routes use the SEO module's resolved pagination

- journalPaginationSource answers runtimeConfig.public.seo.pagination (the
  SEO module's option with its defaults), else the raw seo.pagination
- the module computes the paged routes inside its extendPages callback, so
  an app with only form: 'path' gets /blog/strona/:page and
  /blog/page/:page (L4 WR-03)
This commit is contained in:
Jakub Zych
2026-11-04 22:53:13 +01:00
parent 839db5156c
commit d64fe47adf
4 changed files with 43 additions and 7 deletions

View File

@@ -7,7 +7,7 @@
import { fileURLToPath } from 'node:url'
import { defineNuxtModule, extendPages } from 'nuxt/kit'
import { DEFAULT_JOURNAL_ROUTES, JOURNAL_ROUTE_NAMES, journalPagedRoutes, normalizeJournalRoutes } from '../app/utils/routes.ts'
import { DEFAULT_JOURNAL_ROUTES, JOURNAL_ROUTE_NAMES, journalPagedRoutes, journalPaginationSource, normalizeJournalRoutes } from '../app/utils/routes.ts'
import type { JournalModuleOptions, JournalPostTitleTag, JournalRoutes } from '../app/utils/types.ts'
const PAGE_FILES: Record<keyof JournalRoutes, string> = {
@@ -55,12 +55,13 @@ export default defineNuxtModule<JournalModuleOptions>({
setup(options, nuxt) {
const routes = normalizeJournalRoutes(options.routes as unknown as Record<string, unknown>)
// The path pagination form (vue-seo-layer's seo.pagination.form 'path',
// D-40) adds <listing>/<segment>/:page routes rendering the same pages,
// which read the page from the :page param.
const paged = journalPagedRoutes(routes, (nuxt.options as { seo?: { pagination?: unknown } }).seo?.pagination)
extendPages((pages) => {
// The path pagination form (vue-seo-layer's seo.pagination.form 'path',
// D-40) adds <listing>/<segment>/:page routes rendering the same pages,
// which read the page from the :page param. The segments come from the
// SEO module's resolved option (its defaults included), written in its
// setup, which has run by now (L4 WR-03).
const paged = journalPagedRoutes(routes, journalPaginationSource(nuxt.options))
for (const key of Object.keys(PAGE_FILES) as Array<keyof JournalRoutes>) {
const path = routes[key]
if (path === false) continue