summaryrefslogtreecommitdiffhomepage
path: root/src/components/Pubcomments.astro
diff options
context:
space:
mode:
authorYasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com>2026-11-18 00:09:09 +0900
committerYasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com>2026-11-18 00:09:09 +0900
commit8c2b29f889c75d1d3962d5a3a7b8f9536aebddbe (patch)
tree2d221e564bfe5491b58deb3e39f807d78e2444f5 /src/components/Pubcomments.astro
parent9918d26666e0b7ac466a692d7ebb3d397a405ea8 (diff)
Pubcomments.astro: パブコメ欄をJSONから自動生成するように統合
本文のパブコメ欄と日別一覧の「受付中」表示が同じ pubcomments.json を参照するようにした。募集中・これからの募集・終了した募集はビルド日から自動で振り分ける。
Diffstat (limited to 'src/components/Pubcomments.astro')
-rw-r--r--src/components/Pubcomments.astro62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/components/Pubcomments.astro b/src/components/Pubcomments.astro
new file mode 100644
index 0000000..73521cd
--- /dev/null
+++ b/src/components/Pubcomments.astro
@@ -0,0 +1,62 @@
+---
+// パブリックコメントの一覧。データは src/data/schedule/pubcomments.json から生成する
+// (日別一覧の「受付中」表示も同じJSONを使う)。
+import pubcomments from '@/data/schedule/pubcomments.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}日`;
+};
+
+const items = pubcomments.map((p) => ({
+ ...p,
+ state: todayKey < p.from ? 'upcoming' : todayKey > p.to ? 'ended' : 'open',
+ toLabel:
+ p.from.slice(0, 4) === p.to.slice(0, 4) ? reiwa(p.to).replace(/^令和\d+年|^令和元年/, '') : reiwa(p.to),
+ noteText: p.note ? (p.note.endsWith('。') ? p.note : `${p.note}。`) : '',
+}));
+
+const groups = [
+ { key: 'open', label: '募集中' },
+ { key: 'upcoming', label: 'これからの募集' },
+ { key: 'ended', label: '終了した募集' },
+] as const;
+---
+
+<p>
+ 市は、計画や条例の案について市民の意見を募るパブリックコメント(市民意見公募手続)を行っています。最新の募集状況は、市の<a
+ href="https://www.city.kodaira.tokyo.jp/pubcome/">パブリックコメントのページ</a
+ >でご確認ください。
+</p>
+
+{
+ groups.map((group) => {
+ const list = items.filter((item) => item.state === group.key);
+ if (list.length === 0) return null;
+ return (
+ <>
+ <p>
+ <strong>{group.label}</strong>
+ </p>
+ <ul>
+ {list.map((item) => (
+ <li>
+ <a href={item.url}>{item.title}</a>
+ {`:${reiwa(item.from)}から${item.toLabel}まで${
+ item.state === 'ended' ? '(受付は終了しています)' : ''
+ }。${item.noteText}担当は${item.contact}。`}
+ </li>
+ ))}
+ </ul>
+ </>
+ );
+ })
+}
+
+<p>提出方法や、素案を閲覧できる場所は、それぞれのページをご覧ください。</p>
+<p>(注){reiwa(todayKey)}時点の情報です。</p>