From 78ab3329759daee6c400a1677afcf2be2aefdd18 Mon Sep 17 00:00:00 2001 From: Chris Swithinbank Date: Fri, 14 Jul 2023 20:12:55 +0200 Subject: [PATCH 1/5] Improve injectRoute docs --- .../docs/en/reference/integrations-reference.mdx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/content/docs/en/reference/integrations-reference.mdx b/src/content/docs/en/reference/integrations-reference.mdx index 60eda2974aca0..a6db9c5f18b53 100644 --- a/src/content/docs/en/reference/integrations-reference.mdx +++ b/src/content/docs/en/reference/integrations-reference.mdx @@ -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. pattern: '/foo/[dynamic]', - entryPoint: 'foo/dynamic-page.astro' + // Use relative path syntax for a local route. + entryPoint: './src/foo/dynamic-page.astro' +}); +``` + +An integration designed to be installed in other projects should use its package name to refer to the route entrypoint. +For example, a package published to npm as `@fancy/dashboard`, might inject a dashboard route: + +```js +injectRoute({ + pattern: '/fancy-dashboard', + entryPoint: '@fancy/dashboard/dashboard.astro' }); ``` From ad9f56d65e6f841da2d26ad0fcd2b6ed0c8a3457 Mon Sep 17 00:00:00 2001 From: Chris Swithinbank Date: Fri, 14 Jul 2023 21:48:16 +0200 Subject: [PATCH 2/5] The following is by Sarah Co-authored-by: Sarah Rainsberger --- src/content/docs/en/reference/integrations-reference.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/en/reference/integrations-reference.mdx b/src/content/docs/en/reference/integrations-reference.mdx index a6db9c5f18b53..17eb47293cd12 100644 --- a/src/content/docs/en/reference/integrations-reference.mdx +++ b/src/content/docs/en/reference/integrations-reference.mdx @@ -208,7 +208,7 @@ injectRoute({ ``` An integration designed to be installed in other projects should use its package name to refer to the route entrypoint. -For example, a package published to npm as `@fancy/dashboard`, might inject a dashboard route: +The following example shows a package published to npm as `@fancy/dashboard` injecting a dashboard route: ```js injectRoute({ From 7f7aa16207c1bc7d56041a99cccb71ee7679052d Mon Sep 17 00:00:00 2001 From: Chris Swithinbank Date: Fri, 14 Jul 2023 21:49:49 +0200 Subject: [PATCH 3/5] Calmer nerves Co-authored-by: Sarah Rainsberger --- src/content/docs/en/reference/integrations-reference.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/en/reference/integrations-reference.mdx b/src/content/docs/en/reference/integrations-reference.mdx index 17eb47293cd12..7d779c9b2c916 100644 --- a/src/content/docs/en/reference/integrations-reference.mdx +++ b/src/content/docs/en/reference/integrations-reference.mdx @@ -207,7 +207,7 @@ injectRoute({ }); ``` -An integration designed to be installed in other projects should use its package name to refer to the route entrypoint. +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 From 11d881655ba47e05c7d6c59fd9b4877c6d4f280c Mon Sep 17 00:00:00 2001 From: Chris Swithinbank Date: Fri, 14 Jul 2023 22:54:04 +0200 Subject: [PATCH 4/5] Replace `foo` with something more meaningful --- src/content/docs/en/reference/integrations-reference.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/content/docs/en/reference/integrations-reference.mdx b/src/content/docs/en/reference/integrations-reference.mdx index 7d779c9b2c916..4bf238659bf68 100644 --- a/src/content/docs/en/reference/integrations-reference.mdx +++ b/src/content/docs/en/reference/integrations-reference.mdx @@ -201,9 +201,9 @@ A callback function to inject routes into an Astro project. Injected routes can ```js injectRoute({ // Use Astro’s syntax for dynamic route syntax. - pattern: '/foo/[dynamic]', + pattern: '/subfolder/[dynamic]', // Use relative path syntax for a local route. - entryPoint: './src/foo/dynamic-page.astro' + entryPoint: './src/dynamic-page.astro' }); ``` From 22553d163b51639b75ae07bad34e4a8829877ecc Mon Sep 17 00:00:00 2001 From: Chris Swithinbank Date: Fri, 14 Jul 2023 23:32:18 +0200 Subject: [PATCH 5/5] Sin syntax syntax --- src/content/docs/en/reference/integrations-reference.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/en/reference/integrations-reference.mdx b/src/content/docs/en/reference/integrations-reference.mdx index 4bf238659bf68..357f07e3bfebd 100644 --- a/src/content/docs/en/reference/integrations-reference.mdx +++ b/src/content/docs/en/reference/integrations-reference.mdx @@ -200,7 +200,7 @@ A callback function to inject routes into an Astro project. Injected routes can ```js injectRoute({ - // Use Astro’s syntax for dynamic route syntax. + // Use Astro’s pattern syntax for dynamic routes. pattern: '/subfolder/[dynamic]', // Use relative path syntax for a local route. entryPoint: './src/dynamic-page.astro'