Skip to content

Fix pagination page links on index page - #15

Merged
thibaudcolas merged 1 commit into
mainfrom
fix/index-pagination-links
Sep 10, 2026
Merged

Fix pagination page links on index page#15
thibaudcolas merged 1 commit into
mainfrom
fix/index-pagination-links

Conversation

@thibaudcolas

Copy link
Copy Markdown
Member

Summary

Page 2 / page 3 circles on the index page linked back to / instead of /page/2 and /page/3.

Pagination.astro derives numbered page links by regex-replacing trailing digits from page.url.current (current.replace(/\/\d+$/, /${n})). The paginated routes pass current: '/page/2', which works — but src/pages/index.astro passes current: withBase('/'), which has no trailing digits, so the replace was a no-op and every numbered link resolved to /.

Fix

Derive the /page/N URL pattern from page.url.last instead (always /page/<lastPage> on every paginated route), with page 1 using page.url.first ?? page.url.current.

Verification

Rebuilt the site and extracted every pagination link from the built HTML:

  • / → 2 → /page/2, 3 → /page/3 (the reported bug)
  • /page/2, /page/3, /page/4 → all neighbour links correct
  • /developers/, /developers/page/2 → unaffected, still correct

Rebased on latest main (includes #5).

Numbered page links were derived by regex-replacing trailing digits
from page.url.current, which is '/' on the index page — so pages 2+
linked back to '/'. Derive the /page/N pattern from page.url.last
instead, which is populated on every paginated route.
@thibaudcolas
thibaudcolas merged commit af09093 into main Sep 10, 2026
4 checks passed
@thibaudcolas
thibaudcolas deleted the fix/index-pagination-links branch September 10, 2026 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant