blob: dcf210d2c1cee99078717b8795600a3c0e507b19 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
---
// 行事予定の一覧表。データは src/data/schedule/*.json から読む。
// セルの中身は HTML(リンクを含む)としてそのまま出力する。
import meetings from '@/data/schedule/meetings.json';
import events from '@/data/schedule/events.json';
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[] };
const {
variant,
rows,
scope = 'all',
} = 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="main" のときは、前月以降に開催される予定だけを表示する。
// 前々月以前の終了分はアーカイブに移し、メインページが年々肥大化しないようにする。
if (scope === 'main') {
const start = `${mainStartMonth()}-01`;
list = list.filter((row) =>
entryDates(variant, row.date, row.place).some((date) => date >= start),
);
}
const data: TableData = { columns: base.columns, rows: list };
---
<table>
<thead>
<tr>{data.columns.map((column) => <th>{column}</th>)}</tr>
</thead>
<tbody>
{
data.rows.map((row) => (
<tr>
<td set:html={row.date} />
<td set:html={row.title} />
<td set:html={row.place} />
<td set:html={row.note} />
<td set:html={row.source} />
</tr>
))
}
</tbody>
</table>
|