Skip to content

Commit

Permalink
New: astro add support instructions for integrations and adapters (#…
Browse files Browse the repository at this point in the history
…946)

* new: add astro add instructions for integration authors

* new: add astro add instructions for adapter authors

* fix: link lint (thx hippo!)

* fix: integration -> adapter

* fix: another integration -> adapter

* edit: change myintegration -> example

* edit: add note on peer dependencies

* edit: remove "we will apply your adapter..."

* nit: should -> will

* nit: clarify peer deps on adapter reference

* nit: remove ... to avoid awful HTML
  • Loading branch information
bholmesdev authored Jul 12, 2022
1 parent 49fe58f commit b5388c0
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/pages/en/reference/adapter-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,16 @@ if(app.match(request)) {
```

You can usually call `app.render(request)` without using `.match` because Astro handles 404s if you provide a `404.astro` file. Use `app.match(request)` if you want to handle 404s in a different way.

## Allow installation via `astro add`

[The `astro add` command](/en/reference/cli-reference/#astro-add) allows users to easily add integrations and adapters to their project. If you want _your_ adapter to be installable with this tool, **add `astro-adapter` to the `keywords` field in your `package.json`**:

```json
{
"name": "example",
"keywords": ["astro-adapter"],
}
```

Once you [publish your adapter to npm](https://docs.npmjs.com/cli/v8/commands/npm-publish), running `astro add example` will install your package with any peer dependencies specified in your `package.json`. We will also instruct users to update their project config manually.
27 changes: 27 additions & 0 deletions src/pages/en/reference/integrations-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,33 @@ interface RouteData {
}
```

## Allow installation with `astro add`

[The `astro add` command](/en/reference/cli-reference/#astro-add) allows users to easily add integrations and adapters to their project. If you want _your_ integration to be installable with this tool, **add `astro-integration` to the `keywords` field in your `package.json`**:

```json
{
"name": "example",
"keywords": ["astro-integration"],
}
```

Once you [publish your integration to npm](https://docs.npmjs.com/cli/v8/commands/npm-publish), running `astro add example` will install your package with any peer dependencies specified in your `package.json`. This will also apply your integration to the user's `astro.config` like so:

```diff
// astro.config.mjs
import { defineConfig } from 'astro/config';
+ import example from 'example';
export default defineConfig({
+ integrations: [example()],
})
```

:::caution
This assumes your integration definition is 1) a `default` export and 2) a function. Ensure this is true before adding the `astro-integration` keyword!
:::

## Integration Ordering

All integrations are run in the order that they are configured. For instance, for the array `[react(), svelte()]` in a user's `astro.config.*`, `react` will run before `svelte`.
Expand Down

0 comments on commit b5388c0

Please sign in to comment.