@@ -34,6 +34,35 @@ const { imageUrl, title } = Astro.props;
3434const canonicalURL =
3535 Astro .props .canonicalURL ?? new URL (Astro .url .pathname , Astro .site );
3636const description = Astro .props .description ?? starpodConfig .description ;
37+
38+ function extractDomain(url : string ): string | null {
39+ try {
40+ return new URL (url ).hostname ;
41+ } catch {
42+ return null ;
43+ }
44+ }
45+
46+ function getExternalDomains(): string [] {
47+ const domains = new Set <string >();
48+ const siteHostname = Astro .site ?.hostname ;
49+
50+ // Add RSS feed domain
51+ const feedDomain = extractDomain (starpodConfig .rssFeed );
52+ if (feedDomain && feedDomain !== siteHostname ) {
53+ domains .add (feedDomain );
54+ }
55+
56+ // Add image domain if it's external
57+ const imageDomain = extractDomain (show .image );
58+ if (imageDomain && imageDomain !== siteHostname ) {
59+ domains .add (imageDomain );
60+ }
61+
62+ return Array .from (domains );
63+ }
64+
65+ const externalDomains = getExternalDomains ();
3766---
3867
3968<!doctype html >
@@ -91,7 +120,8 @@ const description = Astro.props.description ?? starpodConfig.description;
91120
92121 <meta property =" og:site_name" content ={ show .title } />
93122
94- <link rel =" preload" as =" image" href ={ show .image } />
123+ <!-- Preload critical resources for faster LCP -->
124+ <link rel =" preload" as =" image" href ={ show .image } fetchpriority =" high" />
95125
96126 <link
97127 crossorigin
@@ -101,6 +131,40 @@ const description = Astro.props.description ?? starpodConfig.description;
101131 type =" font/woff2"
102132 />
103133
134+ <!-- DNS prefetch for external resources -->
135+ {
136+ externalDomains .map ((domain ) => (
137+ <>
138+ <link rel = " dns-prefetch" href = { ` //${domain } ` } />
139+ <link rel = " preconnect" href = { ` https://${domain } ` } crossorigin />
140+ </>
141+ ))
142+ }
143+
144+ <!-- Prefetch for Vercel image optimization -->
145+ { Astro .site && <link rel = " preconnect" href = { Astro .site .origin } />}
146+
147+ <!-- Critical CSS for LCP optimization -->
148+ <style >
149+ /* Critical styles for above-the-fold content */
150+ body {
151+ font-family: 'Inter', system-ui, sans-serif;
152+ margin: 0;
153+ }
154+
155+ .atropos-inner img {
156+ max-width: 100%;
157+ height: auto;
158+ display: block;
159+ }
160+
161+ /* Ensure LCP image renders quickly */
162+ .show-art img {
163+ content-visibility: auto;
164+ contain: layout style paint;
165+ }
166+ </style >
167+
104168 <Schema
105169 slot =" head"
106170 item ={ {
@@ -138,6 +202,7 @@ const description = Astro.props.description ?? starpodConfig.description;
138202 <div class =" relative z-10 mx-auto lg:min-h-full lg:flex-auto" >
139203 <div
140204 class =" bg-light-card dark:bg-dark-card m-2 rounded-lg pt-10 pb-4 lg:pt-16 lg:pb-12"
205+ style =" contain: layout style;"
141206 >
142207 <ShowArtwork image ={ show .image } />
143208
@@ -172,6 +237,7 @@ const description = Astro.props.description ?? starpodConfig.description;
172237 <div class =" relative mt-2 pt-16" >
173238 <div
174239 class =" bg-gradient-light dark:bg-gradient-dark absolute top-0 right-0 left-0 z-0 h-80 w-full opacity-30"
240+ style =" content-visibility: auto;"
175241 >
176242 </div >
177243
0 commit comments