Skip to content

Commit 7a94fdf

Browse files
committed
chore: add changeset
1 parent 6ae93ba commit 7a94fdf

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

.changeset/pink-frogs-poke.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
'astro': minor
3+
---
4+
5+
Adds a new `format` option to the [`paginate`](https://docs.astro.build/en/reference/routing-reference/#paginate) utility. The option `format` is a function that accepts the current URL of the page, and returns a new URL.
6+
7+
For example, you can use `format` to append `.html`; useful for those websites where the URLs contain the `.html` extension.
8+
9+
10+
```astro
11+
---
12+
export async function getStaticPaths({ paginate }) {
13+
// Load your data with fetch(), getCollection(), etc.
14+
const response = await fetch(`https://pokeapi.co/api/v2/pokemon?limit=150`);
15+
const result = await response.json();
16+
const allPokemon = result.results;
17+
18+
// Return a paginated collection of paths for all items
19+
return paginate(allPokemon, {
20+
pageSize: 10,
21+
format: (url) => `${url}.html`
22+
});
23+
}
24+
25+
const { page } = Astro.props;
26+
---
27+
```

0 commit comments

Comments
 (0)