aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorYasutake Yohei <yohei@yasutakeyohei.com>2026-07-01 18:30:50 +0900
committerYasutake Yohei <yohei@yasutakeyohei.com>2026-07-01 18:30:50 +0900
commit6ae791ee8ee72bee88ec852e237a70fefbecd2d0 (patch)
tree4fd61ff4525502dd9d99dd8fc4c37a594e074b6a /src
parent1cfc16c33c6dae3ebd11255143d4fea3a78add3d (diff)
og-image.ts: 一般質問ページの目次サイドバーを非表示に
Diffstat (limited to 'src')
-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");
}
},