From 6c8911bc30cbe4c6e13e522293c154912b01a54e Mon Sep 17 00:00:00 2001 From: Anthony Whitford Date: Thu, 16 Jan 2025 18:29:05 -0800 Subject: [PATCH] Astro v5.0 updates the shape of IntegrationRouteData.distURL to be undefined or an array of URLs. --- packages/plugin-astro/src/index.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/plugin-astro/src/index.ts b/packages/plugin-astro/src/index.ts index c0870fe62..a8b29de5c 100644 --- a/packages/plugin-astro/src/index.ts +++ b/packages/plugin-astro/src/index.ts @@ -58,13 +58,15 @@ async function prepareOramaDb( // All routes are in the same folder, we can use the first one to get the basePath const basePath = dir.pathname.slice(isWindows ? 1 : 0) + // Create a dist urls + const distUrls = routes.flatMap((r) => r.distURL) const pathsToBeIndexed = pages .filter(({ pathname }) => dbConfig.pathMatcher.test(pathname)) .map(({ pathname }) => { // Some pages like 404 are generated as 404.html while others are usually pageName/index.html - const matchingPathname = routes - .find((r) => r.distURL?.pathname.endsWith(pathname.replace(/\/$/, '') + '.html')) - ?.distURL?.pathname?.slice(isWindows ? 1 : 0) + const matchingPathname = distUrls + .find((url) => url?.pathname.endsWith(pathname.replace(/\/$/, '') + '.html')) + ?.pathname?.slice(isWindows ? 1 : 0) return { pathname, generatedFilePath: matchingPathname ?? `${basePath}${pathname.replace(/\/+$/, '')}/index.html`