diff options
| author | Yasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com> | 2026-11-20 14:38:18 +0900 |
|---|---|---|
| committer | Yasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com> | 2026-11-20 14:38:18 +0900 |
| commit | 9c058f6ecc00bff0b69fcc2c963c749531f85ec9 (patch) | |
| tree | 035e4ab9af4758e19eef0022ca4e07f21512b772 /src/components | |
| parent | 7362076ec75e7c324c798aea3355aafa9eb79f29 (diff) | |
ScheduleInteractive.astro: 愛称投票を日別一覧のパブコメ直上に表示
- 独立した段落(Campaigns.astro)は廃止し、日別一覧に1件の予定として出す
- campaigns.json は ScheduleInteractive から読み込み、今日から締切までの日に表示
- 外部リンク(投票フォーム)はスクロール処理の対象外にする
- 冒頭に「内容に誤りがある場合があります」を追記
Diffstat (limited to 'src/components')
| -rw-r--r-- | src/components/Campaigns.astro | 42 | ||||
| -rw-r--r-- | src/components/ScheduleInteractive.astro | 35 |
2 files changed, 27 insertions, 50 deletions
diff --git a/src/components/Campaigns.astro b/src/components/Campaigns.astro deleted file mode 100644 index e0437e9..0000000 --- a/src/components/Campaigns.astro +++ /dev/null @@ -1,42 +0,0 @@ ---- -// 期間限定の投票・意見募集(パブリックコメント以外)。 -// データは 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> - ) -} diff --git a/src/components/ScheduleInteractive.astro b/src/components/ScheduleInteractive.astro index 259d1d2..e409475 100644 --- a/src/components/ScheduleInteractive.astro +++ b/src/components/ScheduleInteractive.astro @@ -3,6 +3,8 @@ import { parseDates, applyExclusions, toKey, keyToDate, entryDates, mainStartMonth, normalizeDigits } from '@/lib/schedule-dates'; // パブリックコメントの受付期間(日別一覧に「受付中」を出すために使う) import pubcomments from '@/data/schedule/pubcomments.json'; + // 期間限定の投票・意見募集(パブコメ以外)。日別一覧に「1件の予定」として出す。 + import campaigns from '@/data/schedule/campaigns.json'; const CATEGORY_DEFS = [ { icon: '👶', label: '子育て' }, @@ -313,14 +315,28 @@ const title = `${date.getMonth() + 1}月${date.getDate()}日(${weekday})の予定`; // その日がパブリックコメントの受付期間内なら、予定の一覧の上に知らせる。 + // 締切は案件ごとに違うので、見出しには日付を出さず、各項目に締切を添える。 + const deadline = (iso) => { + const [, month, day] = iso.split('-').map(Number); + return `${month}月${day}日`; + }; + + // 期間限定の投票・意見募集は、パブコメ受付中の1つ上に、1件の予定として出す。 + const activeCampaigns = campaigns.filter( + (c) => key <= c.to && key >= (c.from || todayKey), + ); + const campaignHtml = activeCampaigns.length + ? `<ul class="schedule-day-campaign">${activeCampaigns + .map( + (c) => + `<li><a class="schedule-day-link" href="${c.url}" target="_blank" rel="noopener noreferrer"><span class="schedule-day-icon">🗳</span>${escapeHtml(c.title)}</a><span class="schedule-day-meta">${deadline(c.to)}まで</span></li>`, + ) + .join('')}</ul>` + : ''; + const activePubcomments = pubcomments.filter((p) => key >= p.from && key <= p.to); let pubcommentHtml = ''; if (activePubcomments.length) { - // 締切は案件ごとに違うので、見出しには日付を出さず、各項目に締切を添える。 - const deadline = (iso) => { - const [, month, day] = iso.split('-').map(Number); - return `${month}月${day}日`; - }; pubcommentHtml = `<div class="schedule-day-pubcomment"> <p class="schedule-day-pubcomment-title">📝 パブリックコメント受付中</p> <ul>${activePubcomments @@ -346,7 +362,7 @@ document.dispatchEvent(new CustomEvent('schedule:day', { detail })); if (list.length === 0) { - detailsEl.innerHTML = `<h3>${title}</h3>${pubcommentHtml}<p>この日の予定はありません。</p>`; + detailsEl.innerHTML = `<h3>${title}</h3>${campaignHtml}${pubcommentHtml}<p>この日の予定はありません。</p>`; return; } @@ -359,10 +375,13 @@ }) .join(''); - detailsEl.innerHTML = `<h3>${title}</h3>${pubcommentHtml}<ul>${items}</ul>`; + detailsEl.innerHTML = `<h3>${title}</h3>${campaignHtml}${pubcommentHtml}<ul>${items}</ul>`; detailsEl.querySelectorAll('a.schedule-day-link').forEach((a) => { a.addEventListener('click', () => { - const row = document.getElementById(a.getAttribute('href').slice(1)); + const href = a.getAttribute('href') ?? ''; + // 外部リンク(投票フォームなど)はそのまま開く + if (/^https?:/i.test(href)) return; + const row = document.getElementById(href.slice(1)); if (!row) return; row.classList.add('schedule-row-highlight'); window.setTimeout(() => row.classList.remove('schedule-row-highlight'), 3000); |
