diff options
Diffstat (limited to 'src/pages')
| -rw-r--r-- | src/pages/kodaira-data/events/[...path].astro | 13 | ||||
| -rw-r--r-- | src/pages/kodaira/events/[period].astro | 29 | ||||
| -rw-r--r-- | src/pages/kodaira/events/feed.xml.ts | 2 |
3 files changed, 29 insertions, 15 deletions
diff --git a/src/pages/kodaira-data/events/[...path].astro b/src/pages/kodaira-data/events/[...path].astro index e09cc30..0eb438b 100644 --- a/src/pages/kodaira-data/events/[...path].astro +++ b/src/pages/kodaira-data/events/[...path].astro @@ -2,12 +2,21 @@ // 旧URL(/kodaira-data/events/2026-11/ など)から新しいURLへの転送。 // 本番のApacheは public/.htaccess が301で返す。astro dev / preview では // .htaccess が効かないため、ここで同じ転送を用意しておく。 -import { fiscalYearKeys, monthKeys } from '@/lib/schedule-months'; +import { + archiveFiscalYearKeys, + archiveMonthKeys, + fiscalYearKeys, + monthKeys, +} from '@/lib/schedule-months'; +import { SCHEDULE_BASE_PATH } from '@/data/schedule/config'; export function getStaticPaths() { return [...monthKeys, ...fiscalYearKeys].map((path) => ({ params: { path } })); } +// アーカイブにある期間はそのページへ、まだアーカイブに移していない期間は +// メインページ(前月以降を掲載)へ送る。 const { path } = Astro.params; -return Astro.redirect(`/kodaira/events/${path}/`, 301); +const archived = [...archiveMonthKeys, ...archiveFiscalYearKeys].includes(path ?? ''); +return Astro.redirect(archived ? `${SCHEDULE_BASE_PATH}${path}/` : SCHEDULE_BASE_PATH, 301); --- diff --git a/src/pages/kodaira/events/[period].astro b/src/pages/kodaira/events/[period].astro index 701d9e3..f2d03df 100644 --- a/src/pages/kodaira/events/[period].astro +++ b/src/pages/kodaira/events/[period].astro @@ -1,14 +1,14 @@ --- -// 月別・年度別アーカイブ(/kodaira/events/2026-11/、/kodaira/events/r8/ など)。 -// 行事予定のデータ(src/data/schedule/*.json)から、その期間の予定だけを静的に生成する。 +// 月別・年度別アーカイブ(/kodaira/events/2026-09/、/kodaira/events/r7/ など)。 +// 前々月以前の予定だけを静的ページにする(前月以降はメインページに載せる)。 import StarlightPage from '@astrojs/starlight/components/StarlightPage.astro'; import ScheduleTable from '@/components/ScheduleTable.astro'; import { - fiscalYearKeys, + archiveFiscalYearKeys, + archiveMonthKeys, fiscalYearLabel, fiscalYearOf, monthCounts, - monthKeys, monthLabel, monthsInFiscalYear, rowsInFiscalYear, @@ -18,22 +18,22 @@ import { SCHEDULE_BASE_PATH } from '@/data/schedule/config'; export function getStaticPaths() { return [ - ...monthKeys.map((key, i) => ({ + ...archiveMonthKeys.map((key, i) => ({ params: { period: key }, props: { kind: 'month' as const, key, - prev: monthKeys[i - 1] ?? null, - next: monthKeys[i + 1] ?? null, + prev: archiveMonthKeys[i - 1] ?? null, + next: archiveMonthKeys[i + 1] ?? null, }, })), - ...fiscalYearKeys.map((key, i) => ({ + ...archiveFiscalYearKeys.map((key, i) => ({ params: { period: key }, props: { kind: 'fiscal' as const, key, - prev: fiscalYearKeys[i - 1] ?? null, - next: fiscalYearKeys[i + 1] ?? null, + prev: archiveFiscalYearKeys[i - 1] ?? null, + next: archiveFiscalYearKeys[i + 1] ?? null, }, })), ]; @@ -58,6 +58,11 @@ const eventRows = // 年度ページでは、その年度の月別ページへの一覧も並べる。 const months = kind === 'fiscal' ? monthsInFiscalYear(key) : []; +// 月別ページから年度ページに戻れるのは、その年度のページが存在するときだけ。 +const fiscalYearForKey = kind === 'month' ? fiscalYearOf(key) : null; +const hasFiscalPage = + fiscalYearForKey !== null && archiveFiscalYearKeys.includes(fiscalYearForKey); + const url = (period: string) => `${SCHEDULE_BASE_PATH}${period}/`; // 期間がすべて過去か、すべて未来か、今日を含むかで説明文を変える。 @@ -133,9 +138,9 @@ const description = isAllPast } { - kind === 'month' && ( + kind === 'month' && hasFiscalPage && fiscalYearForKey && ( <p class="schedule-fiscal-link"> - <a href={url(fiscalYearOf(key))}>{fiscalYearLabel(fiscalYearOf(key))}の予定をまとめて見る</a> + <a href={url(fiscalYearForKey)}>{fiscalYearLabel(fiscalYearForKey)}の予定をまとめて見る</a> </p> ) } diff --git a/src/pages/kodaira/events/feed.xml.ts b/src/pages/kodaira/events/feed.xml.ts index 860f5f2..a76b775 100644 --- a/src/pages/kodaira/events/feed.xml.ts +++ b/src/pages/kodaira/events/feed.xml.ts @@ -46,7 +46,7 @@ const itemXml = ({ item: { type, row }, upcoming }: (typeof entries)[number]) => const datesLabel = upcoming .map((date) => `${Number(date.slice(5, 7))}月${Number(date.slice(8, 10))}日`) .join('、'); - const link = `${SITE_URL}${SCHEDULE_BASE_PATH}${upcoming[0].slice(0, 7)}/`; + const link = `${SITE_URL}${SCHEDULE_BASE_PATH}`; const guid = `${SITE_URL}${SCHEDULE_BASE_PATH}#${type}-${upcoming[0]}-${encodeURIComponent(title)}`; return ` <item> |
