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

@@ -6,6 +6,7 @@ import {
JOURNAL_ROUTE_NAMES,
fillJournalPath,
journalPagedRoutes,
journalPaginationSource,
normalizeJournalRoutes,
} from '../app/utils/routes.ts'
@@ -144,3 +145,19 @@ test('journalPagedRoutes: the query form, no option and disabled views add nothi
path: '/news/p/:page(\\d+)',
})
})
test('journalPaginationSource: the SEO module\'s resolved option, else the raw seo.pagination (L4 WR-03)', () => {
const resolved = { form: 'path', param: 'page', segments: { pl: 'strona', en: 'page' } }
assert.deepEqual(journalPaginationSource({ runtimeConfig: { public: { seo: { pagination: resolved } } }, seo: { pagination: { form: 'path' } } }), resolved)
assert.deepEqual(journalPaginationSource({ runtimeConfig: { public: {} }, seo: { pagination: { form: 'path' } } }), { form: 'path' })
assert.deepEqual(journalPaginationSource({ runtimeConfig: { public: { seo: { cms: true } } }, seo: { pagination: { form: 'query' } } }), { form: 'query' })
assert.equal(journalPaginationSource({}), undefined)
assert.equal(journalPaginationSource(null), undefined)
})
test('journalPagedRoutes: an app that set only form path gets the default pl and en segments through the resolved option', () => {
// vue-seo-layer's setup writes runtimeConfig.public.seo.pagination with its defaults
const nuxtOptions = { seo: { pagination: { form: 'path' } }, runtimeConfig: { public: { seo: { pagination: { form: 'path', param: 'page', segments: { pl: 'strona', en: 'page' } } } } } }
const paths = journalPagedRoutes(normalizeJournalRoutes({ category: false, tag: false, author: false }), journalPaginationSource(nuxtOptions)).map((r) => r.path)
assert.deepEqual(paths, ['/blog/strona/:page(\\d+)', '/blog/page/:page(\\d+)'])
})