Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/content/docs/en/reference/routing-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,39 @@ const { post } = Astro.props;
<h1>{id}: {post.name}</h1>
```

### Accessing route data

<p>

<Since v="5.14.0" />
</p>

A string that can be returned from [`getStaticPaths()`](#getstaticpaths) to access the current [`routePattern`](/en/reference/api-reference/#routepattern).

If a page `src/pages/[...locale]/[files]/[slug].astro` is being rendered, the corresponding `routePattern` is `[...locale]/[files]/[slug]`:

Unlike `params`, which are concrete values for a page, `routePattern` always reflects the original dynamic segment definition in the file path.

```astro title="src/pages/[...locale]/[files]/[slug].astro"
---
export async function getStaticPaths({ routePattern }) {
// Calculate the appropriate params based on the routePattern
const params = [];

// e.g. read route pattern and translate the [files] segment to all locales
if (routePattern.includes("[files]")) {
locales.forEach((locale) => {
params.push({ files: getMessage(locale, "files") });
});
}

return { params };
}

const { page } = Astro.props;
---
```

### `paginate()`

<p>
Expand Down