From a825075f6daafd70c5c36cbf7e45da1dd83122a5 Mon Sep 17 00:00:00 2001 From: Yasutake Yohei Date: Wed, 1 Jul 2026 21:06:36 +0900 Subject: OG画像: 月例会インデックスの年度補完を常時実行に修正 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/og/[slug].png.ts | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/pages/og/[slug].png.ts b/src/pages/og/[slug].png.ts index 33ffc6d..16b61a6 100644 --- a/src/pages/og/[slug].png.ts +++ b/src/pages/og/[slug].png.ts @@ -112,30 +112,28 @@ const stars = [ export async function GET({ params }: { params: { slug: string } }) { const slug = params.slug; - // まずそのままマッチ(kousbunsyo-kanri などの手動ページ) + // まずそのままマッチ(koubunsyo-kanri などの手動ページ) let title = pages[slug]; if (!title) { - // - を / に戻して確認(ippan-situmon-r7d-3gatu → ippan-situmon/r7d/3gatu) const fileSlug = slug.replace(/--/g, "/"); title = pages[fileSlug]; if (!title) { - // 通常のファイル + index.mdx の両方をチェック title = readTitle(path.join(contentDir, fileSlug + ".mdx")) ?? - readTitle(path.join(contentDir, fileSlug, "index.mdx")); - // 一般質問の月例会インデックスページなら年度・月を補完 - if (!title && slug.startsWith("ippan-situmon--")) { - const parts = fileSlug.split("/"); - const reiwa = parts[1]?.replace( - /^r(\d+)d$/, - (_, n) => `令和${n === "1" ? "元" : n}年`, - ); - const month = parts[2]?.replace(/(\d+)gatu/, "$1月"); - if (reiwa && month) title = `${reiwa}${month}定例会`; - } - if (!title) title = "小平市議 安竹洋平 公式サイト"; + readTitle(path.join(contentDir, fileSlug, "index.mdx")) ?? + "小平市議 安竹洋平 公式サイト"; } } + // 一般質問の月例会インデックスページ: 年度・月を補完 + const mm = slug.match(/^ippan-situmon--(r\d+d)--(\d+gatu)$/); + if (mm) { + const reiwa = mm[1].replace( + /^r(\d+)d$/, + (_, n) => `令和${n === "1" ? "元" : n}年`, + ); + const month = mm[2].replace(/(\d+)gatu/, "$1月"); + title = `${reiwa}${month}定例会`; + } const svg = await satori( { -- cgit v1.3.1