Skip to content

Latest commit

 

History

History
50 lines (44 loc) · 1.42 KB

giant-ravens-look.md

File metadata and controls

50 lines (44 loc) · 1.42 KB
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:

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:

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)
            }
        }
    }
}