aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/components/ScheduleTable.astro
diff options
context:
space:
mode:
authorYasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com>2026-11-05 14:40:41 +0900
committerYasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com>2026-11-05 14:40:41 +0900
commit3e02a6a05c6a5b26fbb19fa91be9afbc6b12877d (patch)
treea831354b8f63792048cb336465acb304ed9442e3 /src/components/ScheduleTable.astro
parentacdd88e2d37993b3e2f9890394c14bba71dae965 (diff)
events: メインページの一覧を今月以降に絞る
終了した予定が年々たまって一覧が肥大化するため、一覧表とカレンダーを 今月以降に限定した。過去分は月別・年度別アーカイブに残る。 カレンダーの月移動も今月より前へは戻らないようにした。
Diffstat (limited to 'src/components/ScheduleTable.astro')
-rw-r--r--src/components/ScheduleTable.astro23
1 files changed, 20 insertions, 3 deletions
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>