Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions src/content/docs/en/guides/upgrade-to/v5.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,7 @@ function useRoute(route: IntegrationRouteData) {
}
```

<ReadMore>See the [API reference for `IntegrationRouteData`](/en/reference/integrations-reference/#integrationroutedata-type-reference).</ReadMore>
<ReadMore>See the API reference for `IntegrationRouteData`.</ReadMore>

### Changed: `distURL` is now an array (Integrations API)

Expand All @@ -1139,7 +1139,7 @@ if (route.distURL) {
}
```

<ReadMore>See the [API reference for `IntegrationRouteData`](/en/reference/integrations-reference/#integrationroutedata-type-reference).</ReadMore>
<ReadMore>See the [API reference for `IntegrationRouteData`.</ReadMore>

### Changed: Arguments passed to `app.render()` (Adapter API)

Expand Down
65 changes: 65 additions & 0 deletions src/content/docs/en/guides/upgrade-to/v6.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,71 @@ You may also wish to consider using glob packages from NPM, such as [`fast-glob`

<ReadMore>Learn more about [importing files with `import.meta.glob`](/en/guides/imports/#importmetaglob).</ReadMore>

### Removed: `routes` on `astro:build:done` hook (Integration API)

<SourcePR number="14446" title="feat: cleanup integration api"/>

In Astro 5.0, accessing `routes` on the `astro:build:done` hook was deprecated.

Astro 6.0 removes the `routes` array passed to this hook entirely. Instead, the `astro:routes:resolved` hook should be used.

#### What should I do?

Remove any instance of `routes` passed to `astro:build:done` and replace it with the new `astro:routes:resolved` hook. Access `distURL` on the newly exposed `assets` map:

```js title="my-integration.mjs" ins={2,6-8,11,13-18} del={10}
const integration = () => {
let routes
return {
name: 'my-integration',
hooks: {
'astro:routes:resolved': (params) => {
routes = params.routes
},
'astro:build:done': ({
routes
assets
}) => {
for (const route of routes) {
const distURL = assets.get(route.pattern)
if (distURL) {
Object.assign(route, { distURL })
}
}
console.log(routes)
}
}
}
}
```

<ReadMore>Learn more about [the Integration API `astro:routes:resolved` hook](/en/reference/integrations-reference/#astroroutesresolved) for building integrations.</ReadMore>

### Removed: `entryPoints` on `astro:build:ssr` hook (Integration API)

<SourcePR number="14446" title="feat: cleanup integration api"/>

In Astro 5.0, [`functionPerRoute` was deprecated](/en/guides/upgrade-to/v5/#deprecated-functionperroute-adapter-api). That meant that `entryPoints` on the `astro:build:ssr` hook was always empty.

Astro 6.0 removes the `entryPoints` map passed to this hook entirely.

#### What should I do?

Remove any instance of `entryPoints` passed to `astro:build:ssr`:

```js title="my-integration.mjs" del={6}
const integration = () => {
return {
name: 'my-integration',
hooks: {
'astro:build:ssr': (params) => {
someLogic(params.entryPoints)
},
}
}
}
```

## Changed Defaults

Some default behavior has changed in Astro v5.0 and your project code may need updating to account for these changes.
Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/en/reference/adapter-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ If not provided, Astro will fallback to its default behavior for fetching error
**Default:** `app.match(request)`
</p>

Provide a value for [`integrationRouteData`](/en/reference/integrations-reference/#integrationroutedata-type-reference) if you already know the route to render. Doing so will bypass the internal call to [`app.match`](#appmatch) to determine the route to render.
Provide a value for `integrationRouteData` if you already know the route to render. Doing so will bypass the internal call to [`app.match`](#appmatch) to determine the route to render.

```js "routeData"
const routeData = app.match(request);
Expand Down
186 changes: 0 additions & 186 deletions src/content/docs/en/reference/integrations-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ interface AstroIntegration {
}) => void | Promise<void>;
'astro:build:ssr'?: (options: {
manifest: SerializedSSRManifest;
entryPoints: Map<IntegrationRouteData, URL>;
middlewareEntryPoint: URL | undefined;
logger: AstroIntegrationLogger;
}) => void | Promise<void>;
Expand Down Expand Up @@ -1036,13 +1035,11 @@ export default {
**When:** After a production SSR build has completed.

**Why:** To access the SSR manifest and map of the emitted entry points. This is useful when creating custom SSR builds in plugins or integrations.
- `entryPoints` maps a page route to the physical file emitted after the build;
- `middlewareEntryPoint` is the file system path of the middleware file;

```js
'astro:build:ssr'?: (options: {
manifest: SerializedSSRManifest;
entryPoints: Map<IntegrationRouteData, URL>;
middlewareEntryPoint: URL | undefined;
logger: AstroIntegrationLogger;
}) => void | Promise<void>;
Expand Down Expand Up @@ -1071,29 +1068,6 @@ export default {
}
```

#### `entryPoints` option

<p>

**Type:** <code>Map\<<a href="#integrationroutedata-type-reference">IntegrationRouteData</a>, URL\></code><br />
<Since v="2.7.0" />
</p>

A `Map` of the emitted entry points with the `IntegrationRouteData` as key and the physical file URL as value.

```js
export default {
name: 'my-integration',
hooks: {
'astro:build:ssr': ({ entryPoints }) => {
entryPoints.forEach((url) => {
console.log(url.href);
});
},
},
}
```

#### `middlewareEntryPoint` option

<p>
Expand Down Expand Up @@ -1173,8 +1147,6 @@ export default {
'astro:build:done'?: (options: {
pages: { pathname: string }[];
dir: URL;
/** @deprecated Use the `assets` map and the new `astro:routes:resolved` hook */
routes: IntegrationRouteData[];
assets: Map<string, URL[]>;
logger: AstroIntegrationLogger;
}) => void | Promise<void>;
Expand Down Expand Up @@ -1207,24 +1179,6 @@ export default function myIntegration() {
}
```

#### `routes` option

:::caution
This property is deprecated since v5.0. Check the [migration guide](/en/guides/upgrade-to/v5/#deprecated-routes-on-astrobuilddone-hook-integration-api).
:::

<p>

**Type:** [`IntegrationRouteData[]`](#integrationroutedata-type-reference)
</p>

A list of all generated routes alongside their associated metadata.

You can reference the full `IntegrationRouteData` type below, but the most common properties are:

- `component` - the input file path relative to the project root
- `pathname` - the output file URL (undefined for routes using `[dynamic]` and `[...spread]` params)

#### `assets` option

<p>
Expand Down Expand Up @@ -1496,146 +1450,6 @@ Allows you to access the route to redirect to. This can be a string or an object

Determines if a route comes from Astro core (`internal`), an integration (`external`) or the user's project (`project`).

### `IntegrationRouteData` type reference

:::caution
This type is deprecated since v5.0. Use [`IntegrationResolvedRoute`](#integrationresolvedroute-type-reference) instead.
:::

A smaller version of the `RouteData` that is used in the integrations.

```ts
interface IntegrationRouteData {
type: RouteType;
component: string;
pathname?: string;
pattern: RegExp;
params: string[];
segments: { content: string; dynamic: boolean; spread: boolean; }[][];
generate: (data?: any) => string;
prerender: boolean;
distURL?: URL[];
redirect?: RedirectConfig;
redirectRoute?: IntegrationRouteData;
}
```

#### `type`

<p>

**Type:** `RouteType`
</p>

Allows you to identify the type of the route. The value can be:
- `page`: a route that lives in the file system, usually an Astro component
- `endpoint`: a route that lives in the file system, usually a JS file that exposes endpoints methods
- `redirect`: a route that points to another route that lives in the file system
- `fallback`: a route that doesn't exist in the file system and needs to be handled with other means, usually middleware

#### `component`

<p>

**Type:** `string`
</p>

Allows you to access the source component URL pathname.

#### `pathname`

<p>

**Type:** `string | undefined`
</p>

For regular routes, the value will be the URL pathname where this route will be served. When the project uses [dynamic routes](/en/guides/routing/#dynamic-routes) (ie. `[dynamic]` or `[...spread]`), the pathname will be undefined.

#### `pattern`

<p>

**Type:** `RegExp`
</p>

Allows you to access a regex used for matching an input URL against a requested route.

For example, given a `[fruit]/about.astro` path, the regex will be `/^\/([^/]+?)\/about\/?$/`. Using `pattern.test("banana/about")` will return `true`.

#### `params`

<p>

**Type:** `string[]`
</p>

Allows you to access the route `params`. For example, when a project uses the following [dynamic routes](/en/guides/routing/#dynamic-routes) `/pages/[lang]/[...slug].astro`, the value will be `['lang', '...slug']`.

#### `segments`

<p>

**Type:** `{ content: string; dynamic: boolean; spread: boolean; }[][]`
</p>

Allows you to access the route [`params`](#params-1) with additional metadata. Each object contains the following properties:
* `content`: the `param`,
* `dynamic`: whether the route is dynamic or not,
* `spread`: whether the dynamic route uses the spread syntax or not.

For example, the following route `/pages/[lang]/index.astro` will output the segments `[[ { content: 'lang', dynamic: true, spread: false } ]]`.

#### `generate()`

<p>

**Type:** `(data?: any) => string`
</p>

A function that provides the optional parameters of the route, interpolates them with the route pattern, and returns the path name of the route.

For example, with a route such as `/blog/[...id].astro`, the `generate` function could return:

```js
console.log(generate({ id: 'presentation' })) // will log `/blog/presentation`
```

#### `prerender`

<p>

**Type:** `boolean`
</p>

Determines whether the route is prerendered or not.

#### `distURL`

<p>

**Type:** `URL[] | undefined`
</p>

The paths of the physical files emitted by this route. When a route **isn't** prerendered, the value is either `undefined` or an empty array.

#### `redirect`

<p>

**Type:** <code><a href="https://github.com/withastro/astro/blob/3b10b97a4fecd1dfd959b160a07b5b8427fe40a7/packages/astro/src/types/public/config.ts#L39-L44">RedirectConfig</a> | undefined</code>
</p>

Allows you to access the route to redirect to. This can be a string or an object containing information about the status code and its destination.

#### `redirectRoute`

<p>

**Type:** `IntegrationRouteData | undefined`
</p>

When the value of `RouteData.type` is `redirect`, the value will contains the `IntegrationRouteData` of the route to redirect to. Otherwise, the value will be undefined.

## 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`**:
Expand Down
1 change: 0 additions & 1 deletion src/content/docs/es/guides/internationalization.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,6 @@ Esta característica tiene algunas restricciones:
- La opción `site` es obligatoria.
- La opción `output` debe estar configurada en `"server"`.
- No puede haber páginas prerenderizadas individuales.
- La característica del adaptador [`functionPerRoute`](/es/reference/adapter-reference/#functionperroute) no es admitida.
Astro depende de los siguientes encabezados para admitir la función:
- [`X-Forwarded-Host`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Host) y [`Host`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Host). Astro usará el primero, y si no está presente, intentará el segundo.
- [`X-Forwarded-Proto`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Proto) y [`URL#protocol`](https://developer.mozilla.org/en-US/docs/Web/API/URL/protocol) de la solicitud del servidor.
Expand Down
Loading
Loading