aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/components
diff options
context:
space:
mode:
Diffstat (limited to 'src/components')
-rw-r--r--src/components/ScheduleInteractive.astro7
-rw-r--r--src/components/ScheduleTable.astro23
2 files changed, 25 insertions, 5 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>