From e7b60d5ef8c8cf5471a62498fd0a88f61cd2812e Mon Sep 17 00:00:00 2001 From: Yasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com> Date: Thu, 5 Nov 2026 14:58:06 +0900 Subject: events: メインは前月以降、アーカイブは前々月以前に分ける MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit メインページの一覧とカレンダーを前月以降に広げ、前々月以前の月だけを アーカイブとして生成するようにした。該当が無いときはアーカイブ欄に その旨を表示する。月が進めば自動でページが増える。 RSSと旧URLの転送先も、存在しない月ページを指さないよう合わせた。 --- src/components/ScheduleTable.astro | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/components/ScheduleTable.astro') diff --git a/src/components/ScheduleTable.astro b/src/components/ScheduleTable.astro index e4c59a9..dcf210d 100644 --- a/src/components/ScheduleTable.astro +++ b/src/components/ScheduleTable.astro @@ -3,7 +3,7 @@ // セルの中身は HTML(リンクを含む)としてそのまま出力する。 import meetings from '@/data/schedule/meetings.json'; import events from '@/data/schedule/events.json'; -import { entryDates } from '@/lib/schedule-dates'; +import { entryDates, mainStartMonth } from '@/lib/schedule-dates'; type Row = { date: string; title: string; place: string; note: string; source: string }; type TableData = { columns: string[]; rows: Row[] }; @@ -12,18 +12,17 @@ const { variant, rows, scope = 'all', -} = Astro.props as { variant: 'meeting' | 'event'; rows?: Row[]; scope?: 'all' | 'current' }; +} = Astro.props as { variant: 'meeting' | 'event'; rows?: Row[]; scope?: 'all' | 'main' }; const base: TableData = (variant === 'meeting' ? meetings : events) as TableData; // rows を渡された場合はその行だけを表示する(月別・年度別アーカイブ用) let list = rows ?? base.rows; -// scope="current" のときは、今月以降に開催される予定だけを表示する。 -// 終了した予定は月別アーカイブに移し、メインページが年々肥大化しないようにする。 -if (scope === 'current') { - const now = new Date(); - const monthStart = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-01`; +// scope="main" のときは、前月以降に開催される予定だけを表示する。 +// 前々月以前の終了分はアーカイブに移し、メインページが年々肥大化しないようにする。 +if (scope === 'main') { + const start = `${mainStartMonth()}-01`; list = list.filter((row) => - entryDates(variant, row.date, row.place).some((date) => date >= monthStart), + entryDates(variant, row.date, row.place).some((date) => date >= start), ); } -- cgit v1.3.1