diff --git a/apps/site/src/components/CoverImage.astro b/apps/site/src/components/CoverImage.astro index 943e32ce..0fe17920 100644 --- a/apps/site/src/components/CoverImage.astro +++ b/apps/site/src/components/CoverImage.astro @@ -22,29 +22,41 @@ const { quality = 82, sizes = "(max-width: 768px) 100vw, (max-width: 1280px) 50vw, 960px", priority = false, - class: className = "w-full h-auto aspect-video rounded-md", + class: className = "w-full h-auto aspect-video rounded-md object-cover", } = Astro.props; +const assetRef = stegaClean( + (image as { asset?: { _ref?: string } } | null)?.asset?._ref, +); +const dimMatch = assetRef?.match(/-(\d+)x(\d+)-[a-z0-9]+$/i); +const intrinsicWidth = dimMatch ? Number(dimMatch[1]) : undefined; + const builder = Astro.locals.sanity.urlForImage(image ?? undefined); const aspect = height / width; +const isSquare = width === height; +const maxWidth = intrinsicWidth ? Math.min(width, intrinsicWidth) : width; +const maxHeight = Math.round(maxWidth * aspect); + +const buildUrl = (w: number) => { + if (!builder) return undefined; + const b = builder.width(w); + return (isSquare ? b.height(Math.round(w * aspect)) : b) + .quality(quality) + .url(); +}; -const src = builder - ?.width(width) - .height(height) - .quality(quality) - .url(); +const src = buildUrl(maxWidth); const responsiveWidths = [320, 480, 640, 960, 1280, 1600, 1920].filter( - (w) => w <= width, + (w) => w <= maxWidth, ); -if (!responsiveWidths.includes(width)) { - responsiveWidths.push(width); +if (!responsiveWidths.includes(maxWidth)) { + responsiveWidths.push(maxWidth); } const srcset = builder ? responsiveWidths .map((w) => { - const h = Math.round(w * aspect); - const u = builder.width(w).height(h).quality(quality).url(); + const u = buildUrl(w); return `${u} ${w}w`; }) .join(", ") @@ -63,8 +75,8 @@ const alt = rawAlt && rawAlt.trim().length > 0 ? rawAlt : fallbackAlt; class={className} src={src} srcset={srcset} - width={width} - height={height} + width={maxWidth} + height={maxHeight} alt={alt} loading={priority ? "eager" : "lazy"} fetchpriority={priority ? "high" : "auto"} diff --git a/apps/site/src/components/PodmatchBadge.astro b/apps/site/src/components/PodmatchBadge.astro deleted file mode 100644 index febce45d..00000000 --- a/apps/site/src/components/PodmatchBadge.astro +++ /dev/null @@ -1,59 +0,0 @@ ---- -/** - * Ported from `podmatch-badge.tsx`. The Next version was a client component - * purely for an `onError` fallback on the artwork; `onerror` as an inline - * attribute does the same without hydration. - */ ---- - -
- - diff --git a/apps/site/src/lib/html-to-markdown.ts b/apps/site/src/lib/html-to-markdown.ts index 087d1695..57730c19 100644 --- a/apps/site/src/lib/html-to-markdown.ts +++ b/apps/site/src/lib/html-to-markdown.ts @@ -24,10 +24,6 @@ export function htmlToMarkdown(html: string, pageUrl?: string): string { /- Interested in being a guest on the CodingCat.dev Podcast? We love spotlighting developers building exciting tools, open source libraries, and novel developer experiences. You can connect with us directly via email or through our official PodMatch profile at - PodMatch. + Interested in being a guest on the CodingCat.dev Podcast? We love spotlighting developers building exciting tools, open source libraries, and novel developer experiences. You can connect with us directly via email at + alex@codingcat.dev or schedule a session on our booking page.
- Our website may contain links to external websites, platforms, or services (such as YouTube, GitHub, PodMatch, X, and sponsor sites). We are not responsible for the privacy practices of external platforms. We encourage you to review the privacy policies of any third-party websites you visit. + Our website may contain links to external websites, platforms, or services (such as YouTube, GitHub, X, and sponsor sites). We are not responsible for the privacy practices of external platforms. We encourage you to review the privacy policies of any third-party websites you visit.