Skip to content

Commit

Permalink
Improve injectRoute docs (#3721)
Browse files Browse the repository at this point in the history
Co-authored-by: Sarah Rainsberger <[email protected]>
  • Loading branch information
delucis and sarah11918 authored Jul 17, 2023
1 parent 8fbd915 commit 79b8f9b
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/content/docs/en/reference/integrations-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,24 @@ A callback function to inject routes into an Astro project. Injected routes can
- `pattern` - where the route should be output in the browser, for example `/foo/bar`. A `pattern` can use Astro's filepath syntax for denoting dynamic routes, for example `/foo/[bar]` or `/foo/[...bar]`. Note that a file extension is **not** needed in the `pattern`.
- `entryPoint` - a bare module specifier pointing towards the `.astro` page or `.js`/`.ts` route handler that handles the route denoted in the `pattern`.

Example usage:
##### Example usage

```js
injectRoute({
// Use Astro’s pattern syntax for dynamic routes.
pattern: '/subfolder/[dynamic]',
// Use relative path syntax for a local route.
entryPoint: './src/dynamic-page.astro'
});
```

For an integration designed to be installed in other projects, use its package name to refer to the route entrypoint.
The following example shows a package published to npm as `@fancy/dashboard` injecting a dashboard route:

```js
injectRoute({
pattern: '/foo/[dynamic]',
entryPoint: 'foo/dynamic-page.astro'
pattern: '/fancy-dashboard',
entryPoint: '@fancy/dashboard/dashboard.astro'
});
```

Expand Down

0 comments on commit 79b8f9b

Please sign in to comment.