diff options
| author | Yasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com> | 2026-09-22 11:14:32 +0900 |
|---|---|---|
| committer | Yasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com> | 2026-09-22 11:14:32 +0900 |
| commit | 0ed3c09e909f3adafa7d81313e9aeb63a2727605 (patch) | |
| tree | 63b9943633ffff4861271e3523f4cd5edbf4d7c4 /src/components/Updates.astro | |
| parent | 3bac99dd9615fb70b210b8ec66d23c3f08ab60dd (diff) | |
和暦に統一: 残りの西暦を令和・平成表記にし、更新情報も和暦にする
- コンテンツに残っていた西暦を和暦に変換した(ディスレクシアの各ページの年、
合気公園・いじめ重大事態・実績の年など)
- 「平成28年(2016年)」のような併記は「平成28年」にそろえた
- ホームの「更新情報」の日付を「令和8年9月20日」の形にした(datetime属性は
ISO 8601 のまま)
政策名(2050年カーボンニュートラル)、資料名(理数啓林2014年1月No.4)、計画の
目標年の引用(2030年)、年代表現(2000年代初頭)、英語資料の出典(1987年3月17日)は
そのままにしている。
Diffstat (limited to 'src/components/Updates.astro')
| -rw-r--r-- | src/components/Updates.astro | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/components/Updates.astro b/src/components/Updates.astro index eaf159a..47278fe 100644 --- a/src/components/Updates.astro +++ b/src/components/Updates.astro @@ -6,12 +6,27 @@ type Update = { date: string; title: string; url: string; group: string }; const initial = Number(Astro.props.limit ?? 5); const step = Number(Astro.props.step ?? 10); const items = updates as Update[]; + +/** ISO の日付(YYYY-MM-DD)を「令和8年9月20日」の形にする */ +function toJapaneseDate(iso: string): string { + const [y, m, d] = iso.split("-").map(Number); + let era = "昭和"; + let n = y - 1925; + if (y >= 2019 && !(y === 2019 && m <= 4)) { + era = "令和"; + n = y - 2018; + } else if (y >= 1989) { + era = "平成"; + n = y - 1988; + } + return `${n === 1 ? `${era}元年` : `${era}${n}年`}${m}月${d}日`; +} --- <ul class="updates" data-updates data-step={step}> {items.map((u, index) => ( <li hidden={index >= initial}> - <time datetime={u.date}>{u.date.replace(/-/g, ".")}</time> + <time datetime={u.date}>{toJapaneseDate(u.date)}</time> {u.group && <span class="updates-group">{u.group}</span>} <a href={u.url}>{u.title}</a> </li> |
