From b5b6471b5a5420d1bd410907ac12570b8436702e Mon Sep 17 00:00:00 2001 From: Yasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com> Date: Fri, 23 Oct 2026 09:27:06 +0900 Subject: sanpi: 集計・全期間一覧・前後リンクを修正し、非公開に戻す MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/starlight/Footer.astro | 40 ++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'src/components/starlight/Footer.astro') diff --git a/src/components/starlight/Footer.astro b/src/components/starlight/Footer.astro index 65a61ce..63470a4 100644 --- a/src/components/starlight/Footer.astro +++ b/src/components/starlight/Footer.astro @@ -3,6 +3,7 @@ import Pagination from 'virtual:starlight/components/Pagination'; import config from 'virtual:starlight/user-config'; import { Icon } from '@astrojs/starlight/components'; import SocialShare from '../SocialShare.astro'; +import SanpiPagination from '../SanpiPagination.astro'; import { shareCaption } from '../../utils/share-caption'; const route = Astro.locals.starlightRoute; @@ -32,6 +33,37 @@ function toJapaneseDateTime(date: Date): string { } const lastUpdated = route.lastUpdated; + +// 年度別の賛否一覧はサイドバーに登録していないため、Starlight 標準の +// 前後ページは決まらない。URL から年度を判定し、前年度・次年度を渡す。 +const SANPI_YEARS = [ + { key: 'r1d', label: '令和元年度の賛否一覧' }, + { key: 'r2d', label: '令和2年度の賛否一覧' }, + { key: 'r3d', label: '令和3年度の賛否一覧' }, + { key: 'r4d', label: '令和4年度の賛否一覧' }, + { key: 'r5d', label: '令和5年度の賛否一覧' }, + { key: 'r6d', label: '令和6年度の賛否一覧' }, + { key: 'r7d', label: '令和7年度の賛否一覧' }, + { key: 'r8d', label: '令和8年度の賛否一覧' }, +]; +const sanpiMatch = Astro.url.pathname.match(/^\/sanpi\/(r\d+d)\/?$/); +const sanpiIndex = sanpiMatch + ? SANPI_YEARS.findIndex((year) => year.key === sanpiMatch[1]) + : -1; +const sanpiPrev = + sanpiIndex > 0 + ? { + href: `/sanpi/${SANPI_YEARS[sanpiIndex - 1].key}/`, + label: SANPI_YEARS[sanpiIndex - 1].label, + } + : undefined; +const sanpiNext = + sanpiIndex >= 0 && sanpiIndex < SANPI_YEARS.length - 1 + ? { + href: `/sanpi/${SANPI_YEARS[sanpiIndex + 1].key}/`, + label: SANPI_YEARS[sanpiIndex + 1].label, + } + : undefined; ---