From ff9bafe77a5e0dd84b613bb2aae0bf2a9cb84359 Mon Sep 17 00:00:00 2001 From: Yasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com> Date: Thu, 5 Nov 2026 13:40:32 +0900 Subject: events: 年度別アーカイブとRSSフィードを追加 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 月別ページに加えて、4月〜翌3月の年度ページ(/kodaira/events/r8/)を 追加した。月別リンクは年度ごとにまとめ、今後の予定はfeed.xmlで 配信する。 --- src/lib/schedule-months.ts | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/lib/schedule-months.ts') diff --git a/src/lib/schedule-months.ts b/src/lib/schedule-months.ts index cd109b7..829fef5 100644 --- a/src/lib/schedule-months.ts +++ b/src/lib/schedule-months.ts @@ -42,3 +42,37 @@ export function monthLabel(key: string): string { const [y, m] = key.split('-').map(Number); return `${y}年${m}月`; } + +/** 月キー → 年度キー(令和8年度は r8。4月〜翌年3月) */ +export function fiscalYearOf(month: string): string { + const [y, m] = month.split('-').map(Number); + const startYear = m >= 4 ? y : y - 1; + return `r${startYear - 2018}`; +} + +/** データに存在する年度(昇順) */ +export const fiscalYearKeys: string[] = [...new Set(monthKeys.map(fiscalYearOf))].sort(); + +/** 年度に含まれる月キー(データにある月だけ) */ +export function monthsInFiscalYear(fy: string): string[] { + return monthKeys.filter((month) => fiscalYearOf(month) === fy); +} + +/** 年度の表示(r8 → 令和8年度) */ +export function fiscalYearLabel(fy: string): string { + return `令和${Number(fy.slice(1))}年度`; +} + +/** 複数の月のいずれかに開催される行を返す */ +export function rowsInMonths(months: string[], type: 'meeting' | 'event'): Row[] { + const inMonths = (item: Item) => + datesOf(item).some((date) => months.includes(date.slice(0, 7))); + return items + .filter((item) => item.type === type && inMonths(item)) + .map((item) => item.row); +} + +/** 年度に開催される行を返す */ +export function rowsInFiscalYear(fy: string, type: 'meeting' | 'event'): Row[] { + return rowsInMonths(monthsInFiscalYear(fy), type); +} -- cgit v1.3.1