Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve injectRoute docs #3721

Merged
merged 5 commits into from
Jul 17, 2023
Merged
Changes from 4 commits
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
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 syntax for dynamic route syntax.
delucis marked this conversation as resolved.
Show resolved Hide resolved
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