diff options
| author | Yasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com> | 2026-11-05 14:58:06 +0900 |
|---|---|---|
| committer | Yasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com> | 2026-11-05 14:58:06 +0900 |
| commit | e7b60d5ef8c8cf5471a62498fd0a88f61cd2812e (patch) | |
| tree | 7a7033fc634baa1d7695dd52e90961e98cfc5e16 /src/lib/schedule-dates.ts | |
| parent | 3e02a6a05c6a5b26fbb19fa91be9afbc6b12877d (diff) | |
events: メインは前月以降、アーカイブは前々月以前に分ける
メインページの一覧とカレンダーを前月以降に広げ、前々月以前の月だけを
アーカイブとして生成するようにした。該当が無いときはアーカイブ欄に
その旨を表示する。月が進めば自動でページが増える。
RSSと旧URLの転送先も、存在しない月ページを指さないよう合わせた。
Diffstat (limited to 'src/lib/schedule-dates.ts')
| -rw-r--r-- | src/lib/schedule-dates.ts | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/lib/schedule-dates.ts b/src/lib/schedule-dates.ts index 719a9c6..eaa4a3a 100644 --- a/src/lib/schedule-dates.ts +++ b/src/lib/schedule-dates.ts @@ -148,3 +148,21 @@ export function entryDates( } return [...dates].sort(); } + +const monthKeyOf = (date: Date) => `${date.getFullYear()}-${pad2(date.getMonth() + 1)}`; + +/** + * メインページに載せる範囲の開始月(前月)。例: 2026-11-05 → 2026-10 + * 前月分も残すことで、終わったばかりの予定をメインページで確認できる。 + */ +export function mainStartMonth(now = new Date()): string { + return monthKeyOf(new Date(now.getFullYear(), now.getMonth() - 1, 1)); +} + +/** + * アーカイブ(月別・年度別ページ)に移す範囲の終わり月(前々月)。 + * 例: 2026-11-05 → 2026-09。前月以前はメインページに残す。 + */ +export function archiveEndMonth(now = new Date()): string { + return monthKeyOf(new Date(now.getFullYear(), now.getMonth() - 2, 1)); +} |
