From 0459cc71cd7081d03e51db10e6ae65cb73f9a4f2 Mon Sep 17 00:00:00 2001 From: Yasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com> Date: Thu, 5 Nov 2026 14:24:06 +0900 Subject: events: アーカイブの説明文を期間に合わせて出し分け MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 過去の月にも未来の月にも「開催日が過ぎたものも掲載」と書いていた。 すべて過去・今日を含む・すべて未来の3通りに分け、descriptionも あわせて切り替える。 --- src/pages/kodaira/events/[period].astro | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'src/pages/kodaira/events') diff --git a/src/pages/kodaira/events/[period].astro b/src/pages/kodaira/events/[period].astro index 7ef4599..084760c 100644 --- a/src/pages/kodaira/events/[period].astro +++ b/src/pages/kodaira/events/[period].astro @@ -59,20 +59,41 @@ const eventRows = const months = kind === 'fiscal' ? monthsInFiscalYear(key) : []; const url = (period: string) => `${SCHEDULE_BASE_PATH}${period}/`; + +// 期間がすべて過去か、すべて未来か、今日を含むかで説明文を変える。 +// (過去の月に「今後の予定です」と書いたり、未来の月に「終了分も掲載」と書いたりしない) +const pad = (n: number) => String(n).padStart(2, '0'); +const now = new Date(); +const currentMonth = `${now.getFullYear()}-${pad(now.getMonth() + 1)}`; +const periodMonths = kind === 'fiscal' ? monthsInFiscalYear(key) : [key]; +const firstMonth = periodMonths[0] ?? key; +const lastMonth = periodMonths[periodMonths.length - 1] ?? key; +const isAllPast = lastMonth < currentMonth; +const isAllFuture = firstMonth > currentMonth; + +const lead = isAllPast + ? `${label}の小平市のイベントと、審議会等・市議会の予定を、記録として掲載しています。` + : isAllFuture + ? `${label}の小平市のイベントと、審議会等・市議会の開催予定です。` + : `${label}の小平市のイベントと、審議会等・市議会の開催予定です。開催日が過ぎたものもあわせて掲載しています。`; +const caution = isAllPast + ? '掲載内容は、掲載時点のものです。' + : '変更になることがありますので、各問い合わせ先へご確認ください。'; + +const description = isAllPast + ? `${label}に開催された小平市のイベントと、審議会・市議会の予定の記録です。日程・会場を確認できます。` + : `${label}の小平市のイベントと、審議会・市議会の開催予定の一覧です。日程・会場・申込期限を確認できます。`; ---

← 小平市のイベント・行事予定カレンダー(今後)に戻る

-

- {label}の小平市のイベントと、審議会等・市議会の開催予定です。開催日が過ぎたものも記録として掲載しています。 - 変更になることがありますので、各問い合わせ先へご確認ください。 -

+

{lead}{caution}

{ kind === 'fiscal' && ( -- cgit v1.3.1