From 3e02a6a05c6a5b26fbb19fa91be9afbc6b12877d Mon Sep 17 00:00:00 2001 From: Yasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com> Date: Thu, 5 Nov 2026 14:40:41 +0900 Subject: events: メインページの一覧を今月以降に絞る MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 終了した予定が年々たまって一覧が肥大化するため、一覧表とカレンダーを 今月以降に限定した。過去分は月別・年度別アーカイブに残る。 カレンダーの月移動も今月より前へは戻らないようにした。 --- src/components/ScheduleInteractive.astro | 7 +++++-- src/components/ScheduleTable.astro | 23 ++++++++++++++++++++--- src/content/docs/kodaira/events.mdx | 10 +++++----- 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/components/ScheduleInteractive.astro b/src/components/ScheduleInteractive.astro index 424b453..30569db 100644 --- a/src/components/ScheduleInteractive.astro +++ b/src/components/ScheduleInteractive.astro @@ -100,7 +100,10 @@ const todayKey = toKey(today.getFullYear(), today.getMonth() + 1, today.getDate()); const todayMonth = todayKey.slice(0, 7); // 今日の月もカレンダーで移動できるように含める。 - const months = [...new Set([...dateKeys.map((k) => k.slice(0, 7)), todayMonth])].sort(); + // メインページの一覧は今月以降に絞っているので、カレンダーも過去の月には戻らない。 + const months = [...new Set([...dateKeys.map((k) => k.slice(0, 7)), todayMonth])] + .filter((month) => month >= todayMonth) + .sort(); // 開催日が今日より前のものは「終了」と表示する。 // 複数回の催しで未来の回が残っているものは対象外。 @@ -516,7 +519,7 @@ const councilCount = entries.filter(isCouncil).length; const fields = CATEGORY_DEFS.map((c) => `${c.label}${counts[c.icon] || 0}件`).join('、'); summaryEl.textContent = - `現在の登録件数は、審議会等(会議)${meetingEntries.length}件(うち市議会${councilCount}件)、` + + `このページに載せているのは、審議会等(会議)${meetingEntries.length}件(うち市議会${councilCount}件)、` + `イベント${eventEntries.length}件の合計${entries.length}件です。` + `分野別では、${fields}です(会議とイベントの両方を含みます)。`; } diff --git a/src/components/ScheduleTable.astro b/src/components/ScheduleTable.astro index ff13827..e4c59a9 100644 --- a/src/components/ScheduleTable.astro +++ b/src/components/ScheduleTable.astro @@ -3,14 +3,31 @@ // セルの中身は HTML(リンクを含む)としてそのまま出力する。 import meetings from '@/data/schedule/meetings.json'; import events from '@/data/schedule/events.json'; +import { entryDates } from '@/lib/schedule-dates'; type Row = { date: string; title: string; place: string; note: string; source: string }; type TableData = { columns: string[]; rows: Row[] }; -const { variant, rows } = Astro.props as { variant: 'meeting' | 'event'; rows?: Row[] }; +const { + variant, + rows, + scope = 'all', +} = Astro.props as { variant: 'meeting' | 'event'; rows?: Row[]; scope?: 'all' | 'current' }; const base: TableData = (variant === 'meeting' ? meetings : events) as TableData; -// rows を渡された場合はその行だけを表示する(月別アーカイブ用) -const data: TableData = rows ? { columns: base.columns, rows } : base; +// 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`; + list = list.filter((row) => + entryDates(variant, row.date, row.place).some((date) => date >= monthStart), + ); +} + +const data: TableData = { columns: base.columns, rows: list }; ---