Add format option to paginate() for customizing pagination URLs#17258
Open
astrobot-houston wants to merge 1 commit into
Open
Add format option to paginate() for customizing pagination URLs#17258astrobot-houston wants to merge 1 commit into
format option to paginate() for customizing pagination URLs#17258astrobot-houston wants to merge 1 commit into
Conversation
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
1 task
|
matthewp
requested changes
Jul 1, 2026
matthewp
left a comment
Contributor
There was a problem hiding this comment.
missing a changeset and needs docs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
formatoption toPaginateOptionsthat accepts a(url: string) => stringcallback. When provided, it is applied to all pagination URLs (current,next,prev,first,last) after they are constructed..html(or apply any other transformation) to pagination URLs generated bypaginate().Closes #13604
Testing
describeblocks (8 test cases) topackages/astro/test/units/render/paginate.test.tscovering:formatapplied to all URL properties,formatskipped forundefinedURLs,formatapplied after base path is prepended, and no regression whenformatis omitted.Docs
formatoption is documented inline via JSDoc onPaginateOptions. A docs-site update to thepaginate()reference may be warranted to surface this option for users hitting 404s on static file servers.