summaryrefslogtreecommitdiff
path: root/.changeset/giant-ravens-look.md
diff options
context:
space:
mode:
Diffstat (limited to '.changeset/giant-ravens-look.md')
-rw-r--r--.changeset/giant-ravens-look.md50
1 files changed, 50 insertions, 0 deletions
diff --git a/.changeset/giant-ravens-look.md b/.changeset/giant-ravens-look.md
new file mode 100644
index 000000000..dfa5d6d95
--- /dev/null
+++ b/.changeset/giant-ravens-look.md
@@ -0,0 +1,50 @@
+---
+'astro': minor
+---
+
+Adds a new `astro:routes:resolved` hook to the Integration API. Also update the `astro:build:done` hook by deprecating `routes` and adding a new `assets` map.
+
+When building an integration, you can now get access to routes inside the `astro:routes:resolved` hook:
+
+```js
+const integration = () => {
+ return {
+ name: 'my-integration',
+ hooks: {
+ 'astro:routes:resolved': ({ routes }) => {
+ console.log(routes)
+ }
+ }
+ }
+}
+```
+
+This hook runs before `astro:config:done`, and whenever a route changes in development.
+
+The `routes` array from `astro:build:done` is now deprecated, and exposed properties are now available on `astro:routes:resolved`, except for `distURL`. For this, you can use the newly exposed `assets` map:
+
+```diff
+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)
+ }
+ }
+ }
+}
+``` \ No newline at end of file