aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/components/ScheduleMonthLinks.astro
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/ScheduleMonthLinks.astro')
-rw-r--r--src/components/ScheduleMonthLinks.astro62
1 files changed, 37 insertions, 25 deletions
diff --git a/src/components/ScheduleMonthLinks.astro b/src/components/ScheduleMonthLinks.astro
index adf3b32..61f1ae1 100644
--- a/src/components/ScheduleMonthLinks.astro
+++ b/src/components/ScheduleMonthLinks.astro
@@ -1,40 +1,52 @@
---
// 月別・年度別アーカイブのリンク一覧。行事予定ページの下部に置く。
+// アーカイブは前々月以前の月だけ(前月以降はメインページに掲載している)。
import {
- fiscalYearKeys,
+ archiveFiscalYearKeys,
+ archiveMonthKeys,
fiscalYearLabel,
fiscalYearOf,
monthCounts,
- monthKeys,
monthLabel,
} from '@/lib/schedule-months';
import { scheduleUrl } from '@/data/schedule/config';
-const groups = fiscalYearKeys.map((fy) => ({
+const groups = [...new Set(archiveMonthKeys.map((month) => fiscalYearOf(month)))].map((fy) => ({
key: fy,
label: fiscalYearLabel(fy),
- months: monthKeys.filter((month) => fiscalYearOf(month) === fy),
+ hasPage: archiveFiscalYearKeys.includes(fy),
+ months: archiveMonthKeys.filter((month) => fiscalYearOf(month) === fy),
}));
---
-<div class="schedule-archive">
- {
- groups.map((group) => (
- <section class="schedule-archive-year">
- <h3 class="schedule-archive-year-title">
- <a href={scheduleUrl(`${group.key}/`)}>{group.label}の予定</a>
- </h3>
- <ul class="schedule-archive-months">
- {group.months.map((key) => (
- <li>
- <a href={scheduleUrl(`${key}/`)}>
- <span>{monthLabel(key)}</span>
- <span class="schedule-archive-count">{monthCounts[key]}件</span>
- </a>
- </li>
- ))}
- </ul>
- </section>
- ))
- }
-</div>
+{
+ groups.length === 0 ? (
+ <p class="schedule-archive-empty">
+ 前々月より前に終了した予定はまだありません。月が進むと、ここに過去の予定が表示されます。
+ </p>
+ ) : (
+ <div class="schedule-archive">
+ {groups.map((group) => (
+ <section class="schedule-archive-year">
+ <h3 class="schedule-archive-year-title">
+ {group.hasPage ? (
+ <a href={scheduleUrl(`${group.key}/`)}>{group.label}の予定</a>
+ ) : (
+ group.label
+ )}
+ </h3>
+ <ul class="schedule-archive-months">
+ {group.months.map((key) => (
+ <li>
+ <a href={scheduleUrl(`${key}/`)}>
+ <span>{monthLabel(key)}</span>
+ <span class="schedule-archive-count">{monthCounts[key]}件</span>
+ </a>
+ </li>
+ ))}
+ </ul>
+ </section>
+ ))}
+ </div>
+ )
+}