Skip to content

Commit a450a06

Browse files
authored
Fix OG image localhost fallback; swap frontmatter demo image (#102)
* Fix OG image URL falling back to localhost on prod build makePublicURL() returned http://localhost:3000/ for prod deploys: VERCEL_URL is unset on GitHub Actions, and DEPLOYMENT_ALIAS is only written to $GITHUB_ENV after vercel build runs, so neither is available at build time. Add a main-branch CI guard that returns the canonical URL. * Swap frontmatter demo image to huike-thinking.webp * Update visual snapshots for frontmatter demo image swap * Use CI-native linux render for frontmatter snapshot The jammy-container baseline differed ~5% from ubuntu-latest's webp render (above the 2% tolerance). Replace the two linux baselines with CI's own rendered output so they match the CI environment exactly.
1 parent 619b30b commit a450a06

8 files changed

Lines changed: 9 additions & 2 deletions

astro.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,13 @@ function makePublicURL() {
8989
const VERCEL_URL = process.env.VERCEL_URL;
9090
const DEPLOYMENT_ALIAS = process.env.DEPLOYMENT_ALIAS;
9191

92+
// Prod build on CI: DEPLOYMENT_ALIAS isn't written to the env until *after*
93+
// `vercel build` runs, so detect the main-branch CI build directly and return
94+
// the canonical URL. Without this, OG image URLs fall through to localhost.
95+
if (process.env.CI && process.env.GITHUB_REF === "refs/heads/main") {
96+
return site;
97+
}
98+
9299
// If the site is built on vercel, we can just use VERCEL_URL.
93100
if (VERCEL_URL) return VERCEL_URL;
94101

-211 KB
Loading
109 KB
Loading
-95.8 KB
Loading
23.7 KB
Loading

posts/features/post-with-frontmatter.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Frontmatter"
33
date: "2022-10-04"
4-
img: "/frontmatter/pic.jpg"
4+
img: "/frontmatter/huike-thinking.webp"
55
---
66

77
Imagine that this post was written a long time in the past in a paper notebook,
@@ -20,7 +20,7 @@ Better read [./minimal-note](./minimal-note).
2020
---
2121
title: "Frontmatter"
2222
date: "2022-10-04"
23-
img: "/frontmatter/pic.jpg"
23+
img: "/frontmatter/huike-thinking.webp"
2424
---
2525

2626
Imagine that this post was written a long time in the past in a paper notebook,
62.9 KB
Loading

src/images/frontmatter/pic.jpg

-124 KB
Binary file not shown.

0 commit comments

Comments
 (0)