aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/plugins/og-image.ts16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/plugins/og-image.ts b/src/plugins/og-image.ts
index 3ff1f39..d85f87b 100644
--- a/src/plugins/og-image.ts
+++ b/src/plugins/og-image.ts
@@ -3,10 +3,6 @@ import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
-/**
- * Post-process built HTML files to set per-page og:image.
- * Replaces the default og:image with a page-specific one based on URL path.
- */
export default function ogImageIntegration(): AstroIntegration {
return {
name: "og-image-per-page",
@@ -21,17 +17,13 @@ export default function ogImageIntegration(): AstroIntegration {
let html = fs.readFileSync(htmlPath, "utf-8");
- // 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?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}"`,
);
- // Also update twitter:image
html = html.replace(
/<meta name="twitter:image" content="[^"]*"/g,
`<meta name="twitter:image" content="${ogImageUrl}"`,
@@ -40,6 +32,14 @@ export default function ogImageIntegration(): AstroIntegration {
// Fix breadcrumb: replace directory slug with Japanese label
html = html.replace(/>about-dyslexia</g, `>ディスレクシアについて<`);
+ // 一般質問ページ: 目次サイドバーを非表示
+ if (page.pathname.includes("ippan-situmon")) {
+ html = html.replace(
+ "</head>",
+ "<style>.right-sidebar-container{display:none!important}.main-pane{width:100%!important}</style></head>",
+ );
+ }
+
fs.writeFileSync(htmlPath, html, "utf-8");
}
},