diff options
| author | Yasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com> | 2026-11-05 14:40:41 +0900 |
|---|---|---|
| committer | Yasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com> | 2026-11-05 14:40:41 +0900 |
| commit | 3e02a6a05c6a5b26fbb19fa91be9afbc6b12877d (patch) | |
| tree | a831354b8f63792048cb336465acb304ed9442e3 | |
| parent | acdd88e2d37993b3e2f9890394c14bba71dae965 (diff) | |
events: メインページの一覧を今月以降に絞る
終了した予定が年々たまって一覧が肥大化するため、一覧表とカレンダーを
今月以降に限定した。過去分は月別・年度別アーカイブに残る。
カレンダーの月移動も今月より前へは戻らないようにした。
| -rw-r--r-- | src/components/ScheduleInteractive.astro | 7 | ||||
| -rw-r--r-- | src/components/ScheduleTable.astro | 23 | ||||
| -rw-r--r-- | 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 }; --- <table> diff --git a/src/content/docs/kodaira/events.mdx b/src/content/docs/kodaira/events.mdx index 5cd80e8..9475848 100644 --- a/src/content/docs/kodaira/events.mdx +++ b/src/content/docs/kodaira/events.mdx @@ -55,7 +55,7 @@ import ScheduleMonthLinks from '../../../components/ScheduleMonthLinks.astro'; 位置は、住所をもとにしたおおよその位置です。場所を1点に絞れない予定は地図に表示していません(一覧表には掲載しています)。 -次の「今後のイベント」と「審議会等・市議会の開催予定」は、すべて上のカレンダー・一覧表・地図に反映されています。 +次の「今後のイベント」と「審議会等・市議会の開催予定」は、すべて上のカレンダー・一覧表・地図に反映されています。一覧表は今月以降の予定を掲載し、終了した予定は月別アーカイブに移しています。 ## 今後のイベント @@ -69,7 +69,7 @@ import ScheduleMonthLinks from '../../../components/ScheduleMonthLinks.astro'; <div id="events-table" class="schedule-table"> -<ScheduleTable variant="event" /> +<ScheduleTable variant="event" scope="current" /> </div> @@ -87,7 +87,7 @@ import ScheduleMonthLinks from '../../../components/ScheduleMonthLinks.astro'; <div id="meetings-table" class="schedule-table schedule-table--date-nowrap"> -<ScheduleTable variant="meeting" /> +<ScheduleTable variant="meeting" scope="current" /> </div> @@ -97,7 +97,7 @@ import ScheduleMonthLinks from '../../../components/ScheduleMonthLinks.astro'; ## 月別のアーカイブ -月ごと・年度ごとのページに分けて、それぞれの期間の予定を見られます。 +終了した予定は、月ごと・年度ごとのページに移しています。それぞれの期間の予定を見られます。 <ScheduleMonthLinks /> @@ -109,7 +109,7 @@ import ScheduleMonthLinks from '../../../components/ScheduleMonthLinks.astro'; なお、小川パレット整備プロジェクトでは、10月23日(金)午前10時から令和9年1月20日(水)まで、クラウドファンディングで寄附を募集しています。目標金額は200万円で、ふるさと納税の対象・返礼品なしです。 -<p id="schedule-category-summary" class="schedule-category-summary">現在の登録件数は、カテゴリごとの内訳をここに表示します(JavaScriptが有効なとき)。</p> +<p id="schedule-category-summary" class="schedule-category-summary">このページの掲載件数は、カテゴリごとの内訳をここに表示します(JavaScriptが有効なとき)。</p> ## 情報源 |
