aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYasutake Yohei <yohei@yasutakeyohei.com>2026-07-01 10:47:16 +0900
committerYasutake Yohei <yohei@yasutakeyohei.com>2026-07-01 10:47:16 +0900
commit5ba682d5f70a21adc8e07c5f6131fdf3ce7d543e (patch)
tree4dd6c9c8dcedb4e20ac115dc78aff0d4dbd6535d
parent858399c8eca9e5d8993ffe45eac32687032f2fe7 (diff)
OG画像: twitter:image を追加、URLに ?v=2 を付与
-rw-r--r--astro.config.mjs9
-rw-r--r--src/plugins/og-image.ts9
2 files changed, 15 insertions, 3 deletions
diff --git a/astro.config.mjs b/astro.config.mjs
index 4d5e8e7..4c38017 100644
--- a/astro.config.mjs
+++ b/astro.config.mjs
@@ -183,7 +183,7 @@ export default defineConfig({
tag: "meta",
attrs: {
property: "og:image",
- content: "https://yasutakeyohei.com/og/index.png",
+ content: "https://yasutakeyohei.com/og/index.png?v=2",
},
},
{
@@ -194,6 +194,13 @@ export default defineConfig({
},
},
{
+ tag: "meta",
+ attrs: {
+ name: "twitter:image",
+ content: "https://yasutakeyohei.com/og/index.png?v=2",
+ },
+ },
+ {
tag: "script",
attrs: { type: "application/ld+json" },
content: JSON.stringify({
diff --git a/src/plugins/og-image.ts b/src/plugins/og-image.ts
index 0cfcbc2..c0e14ca 100644
--- a/src/plugins/og-image.ts
+++ b/src/plugins/og-image.ts
@@ -24,12 +24,17 @@ export default function ogImageIntegration(): AstroIntegration {
// Derive slug from pathname: e.g., "/whisper-to-ai-moji-okoshi/" → "whisper-to-ai-moji-okoshi"
let slug = page.pathname.replace(/^\/|\/$/g, "") || "index";
- const ogImageUrl = `https://yasutakeyohei.com/og/${slug}.png`;
+ const ogImageUrl = `https://yasutakeyohei.com/og/${slug}.png?v=2`;
// Replace existing og:image with page-specific one
html = html.replace(
/<meta property="og:image" content="[^"]*"/g,
- `<meta property="og:image" content="${ogImageUrl}"`
+ `<meta property="og:image" content="${ogImageUrl}"`,
+ );
+ // Also update twitter:image
+ html = html.replace(
+ /<meta name="twitter:image" content="[^"]*"/g,
+ `<meta name="twitter:image" content="${ogImageUrl}"`,
);
fs.writeFileSync(htmlPath, html, "utf-8");