-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(underscore-redirects): update API to support new hook (#12924)
- Loading branch information
1 parent
fd12a26
commit 3caa337
Showing
4 changed files
with
72 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@astrojs/underscore-redirects': minor | ||
--- | ||
|
||
Updates how the output is determined in `createRedirectsFromAstroRoutes`. Since `v0.5.0`, the output would use the `buildOutput` property and `config.output` as a fallback. It no longer uses this fallback. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--- | ||
'@astrojs/underscore-redirects': minor | ||
--- | ||
|
||
Updates the input requirements of `createRedirectsFromAstroRoutes`: | ||
|
||
- `routeToDynamicTargetMap` keys are `IntegrationResolvedRoute` instead of `IntegrationRouteData` (obtained from the `astro:routes:resolved` hook) | ||
- There's a new `assets` property, that can be obtained from the `astro:build:done` hook | ||
|
||
```js | ||
function myIntegration() { | ||
let routes | ||
let buildOutput | ||
let config | ||
|
||
return { | ||
name: "my-integration", | ||
hooks: { | ||
"astro:routes:resolved": (params) => { | ||
routes = params.routes | ||
}, | ||
"astro:config:done": (params) => { | ||
buildOutput = params.buildOutput | ||
config = params.config | ||
}, | ||
"astro:build:done": (params) => { | ||
const redirects = createRedirectsFromAstroRoutes({ | ||
config, | ||
buildOutput, | ||
routeToDynamicTargetMap: new Map( | ||
routes.map(route => [route, '']) | ||
), | ||
dir: params.dir, | ||
assets: params.assets | ||
}) | ||
} | ||
} | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters