blob: e0437e9cd13c0ce12878ecdbd3ad8f596441fadf (
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
|
---
// 期間限定の投票・意見募集(パブリックコメント以外)。
// データは src/data/schedule/campaigns.json から読む。
// 期間中(today <= to)だけ表示し、終わったら何も出さない。
import campaigns from '@/data/schedule/campaigns.json';
const pad = (n: number) => String(n).padStart(2, '0');
const now = new Date();
const todayKey = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}`;
const reiwa = (iso: string) => {
const [y, m, d] = iso.split('-').map(Number);
const year = y - 2018 === 1 ? '令和元年' : `令和${y - 2018}年`;
return `${year}${m}月${d}日`;
};
type Campaign = {
title: string;
to: string;
from?: string;
url?: string;
contact: string;
note?: string;
};
const active = (campaigns as Campaign[]).filter(
(c) => todayKey <= c.to && (!c.from || c.from <= todayKey),
);
---
{
active.length > 0 && (
<section class="schedule-campaign">
<h2>募集中(投票・意見募集)</h2>
<ul>
{active.map((c) => (
<li>{c.url ? <a href={c.url}>{c.title}</a> : <strong>{c.title}</strong>}{`:${reiwa(c.to)}まで。${c.note ?? ''}${c.note && !c.note.endsWith('。') ? '。' : ''}担当は${c.contact}。`}</li>
))}
</ul>
</section>
)
}
|