aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorYasutake Yohei <yohei@yasutakeyohei.com>2026-07-01 21:06:36 +0900
committerYasutake Yohei <yohei@yasutakeyohei.com>2026-07-01 21:06:36 +0900
commita825075f6daafd70c5c36cbf7e45da1dd83122a5 (patch)
tree543894cdd71e55ab60db02f0f9659deffd4dd116 /src
parent261bd658f7532c0ee19642882a7c8e36b48317c2 (diff)
OG画像: 月例会インデックスの年度補完を常時実行に修正
Diffstat (limited to 'src')
-rw-r--r--src/pages/og/[slug].png.ts28
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(
{