--- 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; const caption = shareCaption( route.entry?.slug || route.id || '', route.entry?.data?.title, ); /** Date を「令和8年9月22日 11:14」の形にする(ローカル時刻) */ function toJapaneseDateTime(date: Date): string { const y = date.getFullYear(); const m = date.getMonth() + 1; const d = date.getDate(); let era = '昭和'; let n = y - 1925; if (y > 2019 || (y === 2019 && m >= 5)) { era = '令和'; n = y - 2018; } else if (y >= 1989) { era = '平成'; n = y - 1988; } const year = n === 1 ? `${era}元年` : `${era}${n}年`; const hh = String(date.getHours()).padStart(2, '0'); const mm = String(date.getMinutes()).padStart(2, '0'); return `${year}${m}月${d}日 ${hh}:${mm}`; } 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; ---