You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Provides a value for [`integrationResolvedRoute`](/en/reference/integrations-reference/#integrationresolvedroute-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.
526
+
Defines the information about a route. This is useful when you already know the route to render. Doing so will bypass the internal call to [`app.match()`](#appmatch) to determine the route to render.
Allows you to identify the type of route based on its path. Here are some examples of paths associated with their pattern:
@@ -1302,7 +1315,7 @@ Allows you to identify the type of route based on its path. Here are some exampl
1302
1315
1303
1316
<p>
1304
1317
1305
-
**Type:** `RegExp`
1318
+
**Type:** [`RouteData['pattern']`](#pattern-1)
1306
1319
</p>
1307
1320
1308
1321
Allows you to access a regex used for matching an input URL against a requested route.
@@ -1313,7 +1326,7 @@ For example, given a `[fruit]/about.astro` path, the regex will be `/^\/([^/]+?)
1313
1326
1314
1327
<p>
1315
1328
1316
-
**Type:** `string`
1329
+
**Type:** [`RouteData['component']`](#component)
1317
1330
</p>
1318
1331
1319
1332
The URL pathname of the source component.
@@ -1322,7 +1335,7 @@ The URL pathname of the source component.
1322
1335
1323
1336
<p>
1324
1337
1325
-
**Type:** `boolean`
1338
+
**Type:** [`RouteData['prerender']`](#prerender)
1326
1339
</p>
1327
1340
1328
1341
Determines whether the route use [on demand rendering](/en/guides/on-demand-rendering/). The value will be `true` for projects configured with:
@@ -1338,6 +1351,40 @@ Determines whether the route use [on demand rendering](/en/guides/on-demand-rend
1338
1351
1339
1352
When the value of `IntegrationResolvedRoute.type` is `redirect`, the value will be the `IntegrationResolvedRoute` to redirect to. Otherwise, the value will be undefined.
Describes the destination of a redirect. This can be a string or an object containing information about the status code and its destination.
1362
+
1363
+
### `RouteData`
1364
+
1365
+
Describes the information about a route. This contains the following properties:
1366
+
1367
+
#### `route`
1368
+
1369
+
<p>
1370
+
1371
+
**Type:** `string`
1372
+
</p>
1373
+
1374
+
Defines the current route pattern. Here are some examples of paths associated with their pattern:
1375
+
* `src/pages/index.astro` will be `/`
1376
+
* `src/pages/blog/[...slug].astro` will be `/blog/[...slug]`
1377
+
* `src/pages/site/[blog]/[...slug].astro` will be `/site/[blog]/[...slug]`
1378
+
1379
+
#### `component`
1380
+
1381
+
<p>
1382
+
1383
+
**Type:** `string`
1384
+
</p>
1385
+
1386
+
Specifies the source component URL.
1387
+
1341
1388
#### `generate()`
1342
1389
1343
1390
<p>
@@ -1347,10 +1394,10 @@ When the value of `IntegrationResolvedRoute.type` is `redirect`, the value will
1347
1394
1348
1395
A function that provides the optional parameters of the route, interpolates them with the route pattern, and returns the path name of the route.
1349
1396
1350
-
For example, with a route such as `/blog/[...id].astro`, the `generate` function could return:
1397
+
For example, with a route such as `/blog/[...id].astro`, the `generate()` function could return:
1351
1398
1352
1399
```js
1353
-
console.log(generate({ id:'presentation' }))// will log `/blog/presentation`
1400
+
generate({ id:'presentation' }) // will output `/blog/presentation`
1354
1401
```
1355
1402
1356
1403
#### `params`
@@ -1371,11 +1418,32 @@ Allows you to access the route `params`. For example, when a project uses the fo
1371
1418
1372
1419
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.
1373
1420
1421
+
#### `distURL`
1422
+
1423
+
<p>
1424
+
1425
+
**Type:** `URL[] |undefined`<br />
1426
+
<Since v="5.0.0" />
1427
+
</p>
1428
+
1429
+
Defines 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.
1430
+
1431
+
#### `pattern`
1432
+
1433
+
<p>
1434
+
1435
+
**Type:** `RegExp`
1436
+
</p>
1437
+
1438
+
Specifies a regex to use for matching an input URL against a requested route.
1439
+
1440
+
For example, given a `[fruit]/about.astro` path, the regex will be `/^\/([^/]+?)\/about\/?$/`. Using `pattern.test("banana/about")` will return `true`.
* `page`: a route that lives in the file system, usually an Astro component
1580
+
* `endpoint`: a route that lives in the file system, usually a JS file that exposes endpoints methods
1581
+
* `redirect`: a route points to another route that lives in the file system
1582
+
* `fallback`: a route that doesn't exist in the file system that needs to be handled with other means, usually a middleware
1583
+
1584
+
### `ValidRedirectStatus`
1585
+
1586
+
<p>
1587
+
1588
+
**Type:** `301|302|303|307|308|300|304`
1589
+
</p>
1590
+
1591
+
A union of supported redirect status code.
1592
+
1427
1593
## Allow installation with `astro add`
1428
1594
1429
1595
[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`**:
0 commit comments