Skip to content

Add format option to paginate() for customizing pagination URLs#17258

Open
astrobot-houston wants to merge 1 commit into
mainfrom
triagebot/fix-13604
Open

Add format option to paginate() for customizing pagination URLs#17258
astrobot-houston wants to merge 1 commit into
mainfrom
triagebot/fix-13604

Conversation

@astrobot-houston

Copy link
Copy Markdown
Contributor

Changes

  • Adds a format option to PaginateOptions that accepts a (url: string) => string callback. When provided, it is applied to all pagination URLs (current, next, prev, first, last) after they are constructed.
  • This is a non-breaking, opt-in addition — default behavior is completely unchanged. Users deploying to static file servers without URL rewrite rules can now use this to append .html (or apply any other transformation) to pagination URLs generated by paginate().
paginate(items, {
  pageSize: 10,
  format: (url) => `${url}.html`,
})

Closes #13604

Testing

  • Added 3 new describe blocks (8 test cases) to packages/astro/test/units/render/paginate.test.ts covering: format applied to all URL properties, format skipped for undefined URLs, format applied after base path is prepended, and no regression when format is omitted.

Docs

  • The new format option is documented inline via JSDoc on PaginateOptions. A docs-site update to the paginate() reference may be warranted to surface this option for users hitting 404s on static file servers.

Add a `format` option to `PaginateOptions` that accepts a callback
`(url: string) => string` to transform pagination URLs (current, next,
prev, first, last) before they are set on the page result.

This allows users deploying to static file servers that don't support
clean URLs to add file extensions like `.html`:

  paginate(items, {
    format: (url) => `${url}.html`,
  })

Fixes #13604
@astrobot-houston astrobot-houston added the fix verified Reporter confirmed the triage bot fix works label Jul 1, 2026
@changeset-bot

changeset-bot Bot commented Jul 1, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: daa9ae8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions Bot added pkg: astro Related to the core `astro` package (scope) docs pr labels Jul 1, 2026

@matthewp matthewp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing a changeset and needs docs

@matthewp matthewp added this to the 7.1 milestone Jul 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs pr fix verified Reporter confirmed the triage bot fix works pkg: astro Related to the core `astro` package (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pagination not using .html files generated by build

2 participants