Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions apps/site/src/components/CoverMedia.astro
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,21 @@ interface Props {
image?: (SanityImageSource & { alt?: string }) | null;
video?: { asset?: { _ref?: string } } | null;
youtube?: string | null;
width?: number;
height?: number;
sizes?: string;
class?: string;
}

const { image, video, youtube, class: className } = Astro.props;
const {
image,
video,
youtube,
width,
height,
sizes = "(max-width: 1280px) 100vw, 1280px",
class: className,
} = Astro.props;

/**
* Sanity file refs are `file-{hash}-{ext}`. The Next version read the project
Expand Down Expand Up @@ -62,6 +73,13 @@ const youtubeUrl = stegaClean(youtube);
isInline={false}
/>
) : (
<CoverImage image={image} priority sizes="(max-width: 1280px) 100vw, 1280px" class={className} />
<CoverImage
image={image}
width={width}
height={height}
priority
sizes={sizes}
class={className}
/>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const components = {

{
value && value.length > 0 && (
<div class:list={["prose dark:prose-invert max-w-none", className]}>
<div class:list={["prose dark:prose-invert max-w-4xl", className]}>
<PortableText value={value} components={components} />
</div>
)
Expand Down
41 changes: 31 additions & 10 deletions apps/site/src/components/portable-text/PtImage.astro
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,46 @@ type Props = PtProps<ImageNode>;

const { node } = Astro.props;

const src = Astro.locals.sanity
.urlForImage(node)
?.width(1920)
.height(1080)
.url();
// Parse intrinsic dimensions from Sanity asset _ref ("image-<hash>-<width>x<height>-<ext>")
// so we never pass a forced 16:9 .height(1080) to @sanity/image-url (which causes
// @sanity/image-url to inject ?rect=... and crop tall/square images like memes or diagrams).
const assetRef = stegaClean(
(node as { asset?: { _ref?: string } })?.asset?._ref,
);
const dimMatch = assetRef?.match(/-(\d+)x(\d+)-[a-z0-9]+$/i);
const intrinsicWidth = dimMatch ? Number(dimMatch[1]) : 1200;
const intrinsicHeight = dimMatch ? Number(dimMatch[2]) : 675;

const builder = Astro.locals.sanity.urlForImage(node);
const maxWidth = Math.min(intrinsicWidth, 1600);
const src = builder?.width(maxWidth).quality(82).url();

const responsiveWidths = [480, 640, 800, 960, 1200, 1600].filter(
(w) => w <= maxWidth,
);
if (!responsiveWidths.includes(maxWidth)) {
responsiveWidths.push(maxWidth);
}
const srcset = builder
? responsiveWidths
.map((w) => `${builder.width(w).quality(82).url()} ${w}w`)
.join(", ")
: undefined;

const alt = stegaClean(node.alt) ?? "";
const caption = node.caption;
---

{
src && (
<figure class="not-prose my-8">
<figure class="not-prose my-8 flex flex-col items-center">
<img
class="w-full h-auto rounded-md shadow-md"
class="h-auto w-auto max-w-full max-h-[80dvh] rounded-md shadow-md"
src={src}
width={1920}
height={1080}
sizes="100vw"
srcset={srcset}
width={intrinsicWidth}
height={intrinsicHeight}
sizes="(max-width: 896px) 100vw, 896px"
alt={alt}
loading="lazy"
decoding="async"
Expand Down
3 changes: 3 additions & 0 deletions apps/site/src/pages/author/[slug].astro
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ const relatedPodcasts = (person.related?.podcast ?? []) as ContentListItem[];
<div class="shrink-0">
<CoverMedia
image={person.coverImage}
width={256}
height={256}
sizes="128px"
class="size-24 rounded-md object-cover md:size-32"
/>
</div>
Expand Down
3 changes: 3 additions & 0 deletions apps/site/src/pages/guest/[slug].astro
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ const relatedPodcasts = (person.related?.podcast ?? []) as ContentListItem[];
<div class="shrink-0">
<CoverMedia
image={person.coverImage}
width={256}
height={256}
sizes="128px"
class="size-24 rounded-md object-cover md:size-32"
/>
</div>
Expand Down
2 changes: 1 addition & 1 deletion apps/site/src/pages/podcast/[slug].astro
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ const faqNode = faqSchema(extractFaqsFromPortableText(podcast.content));

{
podcast.transcript?.summary && (
<section class="my-8 rounded-xl border border-border bg-card/50 p-6">
<section class="my-8 mx-auto max-w-4xl rounded-xl border border-border bg-card/50 p-6">
<h2 class="mb-3 text-xl font-bold">Episode Summary</h2>
<p class="leading-relaxed text-muted-foreground">
{podcast.transcript.summary}
Expand Down
2 changes: 1 addition & 1 deletion apps/site/src/pages/post/[slug].astro
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ const faqNode = faqSchema(extractFaqsFromPortableText(post.content));

{
post.transcript?.summary && (
<section class="my-8 rounded-xl border border-border bg-card/50 p-6">
<section class="my-8 mx-auto max-w-4xl rounded-xl border border-border bg-card/50 p-6">
<h2 class="mb-3 text-xl font-bold">Video Summary</h2>
<p class="leading-relaxed text-muted-foreground">
{post.transcript.summary}
Expand Down
3 changes: 3 additions & 0 deletions apps/site/src/pages/sponsor/[slug].astro
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ const relatedPodcasts = (sponsor.related?.podcast ?? []) as ContentListItem[];
<div class="shrink-0">
<CoverMedia
image={sponsor.coverImage}
width={256}
height={256}
sizes="128px"
class="size-24 rounded-md object-cover md:size-32"
/>
</div>
Expand Down
Binary file added scripts/assets/php2shell-cover.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added scripts/assets/php2shell-meme.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions scripts/backfill-content-from-transcripts.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createClient } from "@sanity/client";
import { publishPhp2ShellPost } from "./publish-php2shell-post.mjs";

const projectId = process.env.SANITY_STUDIO_PROJECT_ID || "hfh83o0w";
const dataset = process.env.SANITY_STUDIO_DATASET || "production";
Expand Down Expand Up @@ -173,6 +174,9 @@ async function run() {
.then(() => console.log(`✓ Successfully updated ${doc2Id}`))
.catch((err) => console.error(`✗ Error updating ${doc2Id}:`, err.message));

// 3. Publish PHP2Shell blog post & patch missing excerpts
await publishPhp2ShellPost();

console.log("Backfill complete!");
}

Expand Down
Loading
Loading