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 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
16 changes: 14 additions & 2 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: '/foo/[dynamic]',
delucis marked this conversation as resolved.
Show resolved Hide resolved
entryPoint: 'foo/dynamic-page.astro'
// Use relative path syntax for a local route.
entryPoint: './src/foo/dynamic-page.astro'
delucis marked this conversation as resolved.
Show resolved Hide resolved
delucis marked this conversation as resolved.
Show resolved Hide resolved
});
```

An integration designed to be installed in other projects should use its package name to refer to the route entrypoint.
delucis marked this conversation as resolved.
Show resolved Hide resolved
For example, a package published to npm as `@fancy/dashboard`, might inject a dashboard route:
delucis marked this conversation as resolved.
Show resolved Hide resolved

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

Expand Down