aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/components
diff options
context:
space:
mode:
Diffstat (limited to 'src/components')
-rw-r--r--src/components/ScheduleInteractive.astro6
-rw-r--r--src/components/ScheduleMonthLinks.astro62
-rw-r--r--src/components/ScheduleTable.astro15
3 files changed, 47 insertions, 36 deletions
diff --git a/src/components/ScheduleInteractive.astro b/src/components/ScheduleInteractive.astro
index 30569db..f0bd73c 100644
--- a/src/components/ScheduleInteractive.astro
+++ b/src/components/ScheduleInteractive.astro
@@ -1,7 +1,7 @@
<script>
// URLは src/data/schedule/config.ts で一元管理している(ページ移転時はそこだけ変える)
import { scheduleAbsoluteUrl } from '@/data/schedule/config';
- import { parseDates, applyExclusions, toKey, keyToDate, entryDates } from '@/lib/schedule-dates';
+ import { parseDates, applyExclusions, toKey, keyToDate, entryDates, mainStartMonth } from '@/lib/schedule-dates';
const CATEGORY_DEFS = [
{ icon: '👶', label: '子育て' },
@@ -100,9 +100,9 @@
const todayKey = toKey(today.getFullYear(), today.getMonth() + 1, today.getDate());
const todayMonth = todayKey.slice(0, 7);
// 今日の月もカレンダーで移動できるように含める。
- // メインページの一覧は今月以降に絞っているので、カレンダーも過去の月には戻らない。
+ // メインページの一覧は前月以降に絞っているので、カレンダーも前々月以前には戻らない。
const months = [...new Set([...dateKeys.map((k) => k.slice(0, 7)), todayMonth])]
- .filter((month) => month >= todayMonth)
+ .filter((month) => month >= mainStartMonth())
.sort();
// 開催日が今日より前のものは「終了」と表示する。
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>
+ )
+}
diff --git a/src/components/ScheduleTable.astro b/src/components/ScheduleTable.astro
index e4c59a9..dcf210d 100644
--- a/src/components/ScheduleTable.astro
+++ b/src/components/ScheduleTable.astro
@@ -3,7 +3,7 @@
// セルの中身は HTML(リンクを含む)としてそのまま出力する。
import meetings from '@/data/schedule/meetings.json';
import events from '@/data/schedule/events.json';
-import { entryDates } from '@/lib/schedule-dates';
+import { entryDates, mainStartMonth } from '@/lib/schedule-dates';
type Row = { date: string; title: string; place: string; note: string; source: string };
type TableData = { columns: string[]; rows: Row[] };
@@ -12,18 +12,17 @@ const {
variant,
rows,
scope = 'all',
-} = Astro.props as { variant: 'meeting' | 'event'; rows?: Row[]; scope?: 'all' | 'current' };
+} = Astro.props as { variant: 'meeting' | 'event'; rows?: Row[]; scope?: 'all' | 'main' };
const base: TableData = (variant === 'meeting' ? meetings : events) as TableData;
// rows を渡された場合はその行だけを表示する(月別・年度別アーカイブ用)
let list = rows ?? base.rows;
-// scope="current" のときは、今月以降に開催される予定だけを表示する。
-// 終了した予定は月別アーカイブに移し、メインページが年々肥大化しないようにする。
-if (scope === 'current') {
- const now = new Date();
- const monthStart = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-01`;
+// scope="main" のときは、前月以降に開催される予定だけを表示する。
+// 前々月以前の終了分はアーカイブに移し、メインページが年々肥大化しないようにする。
+if (scope === 'main') {
+ const start = `${mainStartMonth()}-01`;
list = list.filter((row) =>
- entryDates(variant, row.date, row.place).some((date) => date >= monthStart),
+ entryDates(variant, row.date, row.place).some((date) => date >= start),
);
}