diff options
| -rw-r--r-- | src/pages/og/[slug].png.ts | 28 |
1 files 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( { |
