Skip to content

Commit 1f7ec7d

Browse files
fix: changelog code snippet (#14443)
1 parent a3e16ab commit 1f7ec7d

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

packages/astro/CHANGELOG.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,22 @@
1111
For example, you can now localize your route segments and return an array of static paths by passing `routePattern` to a custom `getLocalizedData()` helper function. The `params` object will be set with explicit values for each route segment (e.g. `locale`, `files`, and `slug)`. Then, these values will be used to generate the routes and can be used in your page template via `Astro.params`.
1212

1313
```astro
14+
---
1415
// src/pages/[...locale]/[files]/[slug].astro
16+
import { getLocalizedData } from "../../../utils/i18n";
17+
18+
export async function getStaticPaths({ routePattern }) {
19+
const response = await fetch('...');
20+
const data = await response.json();
21+
22+
console.log(routePattern); // [...locale]/[files]/[slug]
1523
16-
import { getLocalizedData } from "../../../utils/i18n"; export async function getStaticPaths({ routePattern
17-
}) { const response = await fetch('...'); const data = await response.json(); console.log(routePattern);
18-
// [...locale]/[files]/[slug] // Call your custom helper with `routePattern` to generate the static
19-
paths return data.flatMap((file) => getLocalizedData(file, routePattern)); } const { locale, files,
20-
slug } = Astro.params;
24+
// Call your custom helper with `routePattern` to generate the static paths
25+
return data.flatMap((file) => getLocalizedData(file, routePattern));
26+
}
27+
28+
const { locale, files, slug } = Astro.params;
29+
---
2130
```
2231

2332
For more information about this advanced routing pattern, see Astro's [routing reference](https://docs.astro.build/en/reference/routing-reference/#routepattern).

0 commit comments

Comments
 (0)