pls
All checks were successful
Ascently - Docs Deploy / build-and-push (push) Successful in 3m58s

This commit is contained in:
2026-01-10 02:03:24 -07:00
parent 1a85dab6ae
commit d97a5f36ea
2 changed files with 35 additions and 0 deletions

View File

@@ -55,4 +55,8 @@ export default defineConfig({
adapter: node({ adapter: node({
mode: "standalone", mode: "standalone",
}), }),
build: {
inlineStylesheets: "always",
},
}); });

31
docs/src/middleware.ts Normal file
View File

@@ -0,0 +1,31 @@
import { defineMiddleware } from "astro:middleware";
export const onRequest = defineMiddleware(async (_, next) => {
const response = await next();
const contentType = response.headers.get("Content-Type") || "";
// Only modify HTML responses
if (contentType.includes("text/html")) {
const html = await response.text();
// Optimize LCP image by setting fetchpriority="high" on the hero image
// Target specific image by its alt text seen in PageSpeed Insights
const optimizedHtml = html.replace(
/<img([^>]*?)alt="Ascently app icon"([^>]*?)>/,
(match, p1, p2) => {
if (match.includes("fetchpriority=")) {
return match.replace(/fetchpriority="[^"]*"/, 'fetchpriority="high"');
}
return `<img${p1}alt="Ascently app icon" fetchpriority="high"${p2}>`;
}
);
return new Response(optimizedHtml, {
status: response.status,
headers: response.headers,
});
}
return response;
});