diff --git a/src/core/prerender/prerender.ts b/src/core/prerender/prerender.ts index 499852bdaa..e6557a6f4f 100644 --- a/src/core/prerender/prerender.ts +++ b/src/core/prerender/prerender.ts @@ -278,7 +278,7 @@ export async function prerender(nitro: Nitro) { // Crawl route links if (!_route.error && (isImplicitHTML || route.endsWith(".html"))) { - const extractedLinks = extractLinks( + const extractedLinks = await extractLinks( dataBuff.toString("utf8"), route, res, diff --git a/src/core/prerender/utils.ts b/src/core/prerender/utils.ts index a1c1635bac..37e7c92abc 100644 --- a/src/core/prerender/utils.ts +++ b/src/core/prerender/utils.ts @@ -1,7 +1,7 @@ import { colors } from "consola/utils"; import type { PrerenderRoute } from "nitropack/types"; import { parseURL } from "ufo"; -import { parse as parseHTML, walkSync } from "ultrahtml"; +import { parse as parseHTML, walk } from "ultrahtml"; const allowedExtensions = new Set(["", ".json"]); @@ -22,7 +22,7 @@ function escapeHtml(text: string) { ); } -export function extractLinks( +export async function extractLinks( html: string, from: string, res: Response, @@ -33,7 +33,7 @@ export function extractLinks( // Extract from any to crawl if (crawlLinks) { - walkSync(parseHTML(html), (node) => { + await walk(parseHTML(html), (node) => { if (!node.attributes.href) { return; }