aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/components/starlight
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/starlight')
-rw-r--r--src/components/starlight/Footer.astro40
1 files changed, 39 insertions, 1 deletions
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;
---
<footer class="sl-flex">
@@ -55,7 +87,13 @@ const lastUpdated = route.lastUpdated;
)
}
</div>
- <Pagination />
+ {
+ sanpiIndex >= 0 ? (
+ <SanpiPagination prev={sanpiPrev} next={sanpiNext} />
+ ) : (
+ <Pagination />
+ )
+ }
{
config.credits && (