Add link-preview image and Open Graph/Twitter tags

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbertandClaude Haiku 5.5 committed 2026-10-09 03:57:18 +01:00
1 parent d73ea4958f
commit f7bd7df579
4 files changed
+13 -2

No files matched your search

+1
View File
@@ -25,6 +25,7 @@ services:
VITE_CV_URL: "${VITE_CV_URL:-/CV/my_cv.pdf}" # e.g. /CV/your-cv.pdf; empty hides CV buttons VITE_CV_URL: "${VITE_CV_URL:-/CV/my_cv.pdf}" # e.g. /CV/your-cv.pdf; empty hides CV buttons
GITHUB_TOKEN: "${GITHUB_TOKEN:-}" # read-only PAT, set in the gitignored root .env; empty disables the contribution graph GITHUB_TOKEN: "${GITHUB_TOKEN:-}" # read-only PAT, set in the gitignored root .env; empty disables the contribution graph
ALLOWED_ORIGIN: "${ALLOWED_ORIGIN:-http://localhost:3001}" ALLOWED_ORIGIN: "${ALLOWED_ORIGIN:-http://localhost:3001}"
SITE_URL: "${SITE_URL:-http://localhost:3001}" # public address, used in link-preview tags
FORCE_HTTPS: "${FORCE_HTTPS:-false}" FORCE_HTTPS: "${FORCE_HTTPS:-false}"
# Only if you set VITE_CV_URL: the CV is never baked into the image. # Only if you set VITE_CV_URL: the CV is never baked into the image.
volumes: volumes:
+9 -1
View File
@@ -14,13 +14,21 @@
name="description" name="description"
content="__SITE_NAME__, graduate software engineer. Projects, skills, and a homelab." content="__SITE_NAME__, graduate software engineer. Projects, skills, and a homelab."
/> />
<link rel="canonical" href="__SITE_URL__/" />
<meta property="og:type" content="website" /> <meta property="og:type" content="website" />
<meta property="og:site_name" content="__SITE_NAME__" />
<meta property="og:url" content="__SITE_URL__/" />
<meta property="og:image" content="__SITE_URL__/og-image.jpg" />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
<meta property="og:image:alt" content="__SITE_NAME__, graduate software engineer" />
<meta property="og:title" content="__SITE_NAME__, Graduate Software Engineer" /> <meta property="og:title" content="__SITE_NAME__, Graduate Software Engineer" />
<meta <meta
property="og:description" property="og:description"
content="Graduate software engineer. Projects, skills, and a homelab." content="Graduate software engineer. Projects, skills, and a homelab."
/> />
<meta name="twitter:card" content="summary" /> <meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:image" content="__SITE_URL__/og-image.jpg" />
<title>__SITE_NAME__, Graduate Software Engineer</title> <title>__SITE_NAME__, Graduate Software Engineer</title>
</head> </head>
<body> <body>
Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

+3 -1
View File
@@ -199,7 +199,9 @@ let indexHtml = "";
try { try {
indexHtml = fs indexHtml = fs
.readFileSync(path.join(distPath, "index.html"), "utf8") .readFileSync(path.join(distPath, "index.html"), "utf8")
.replaceAll("__SITE_NAME__", escapeHtml(publicEnv.VITE_NAME || "Your Name")); .replaceAll("__SITE_NAME__", escapeHtml(publicEnv.VITE_NAME || "Your Name"))
// Absolute URLs for link previews (og:image needs one). Set SITE_URL to the public address.
.replaceAll("__SITE_URL__", escapeHtml((process.env.SITE_URL || ALLOWED_ORIGIN).replace(/\/$/, "")));
} catch { } catch {
console.warn("dist/index.html not found, run `npm run build` first"); console.warn("dist/index.html not found, run `npm run build` first");
} }