aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/components/starlight
diff options
context:
space:
mode:
authorYasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com>2026-09-16 14:48:14 +0900
committerYasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com>2026-09-16 14:48:14 +0900
commit9526b35ed1bc8e48837da16dd88ee78b2be6187e (patch)
tree8973a5653789bb6927c068d7df93ae33bb8aa4a7 /src/components/starlight
parent88d3a913318029addbc87cabf2afe6279cdccf91 (diff)
Breadcrumbs: 構造化データを追加し、ディスレクシアのラベルを修正
Diffstat (limited to 'src/components/starlight')
-rw-r--r--src/components/starlight/Breadcrumbs.astro51
1 files changed, 37 insertions, 14 deletions
diff --git a/src/components/starlight/Breadcrumbs.astro b/src/components/starlight/Breadcrumbs.astro
index 8f7aba0..bd65fec 100644
--- a/src/components/starlight/Breadcrumbs.astro
+++ b/src/components/starlight/Breadcrumbs.astro
@@ -22,9 +22,25 @@ if (breadcrumbs.length > 0) {
breadcrumbs[breadcrumbs.length - 1].label = route.entry?.data?.title || breadcrumbs[breadcrumbs.length - 1].label;
}
+// パンくずリストの構造化データ(BreadcrumbList)
+const siteUrl = Astro.site ?? new URL(Astro.url.origin);
+const breadcrumbList = {
+ '@context': 'https://schema.org',
+ '@type': 'BreadcrumbList',
+ itemListElement: [{ label: 'ホーム', href: '/' }, ...breadcrumbs].map(
+ (crumb, i) => ({
+ '@type': 'ListItem',
+ position: i + 1,
+ name: crumb.label,
+ item: new URL(crumb.href, siteUrl).href,
+ }),
+ ),
+};
+
function labelMap(segment: string): string | null {
const map: Record<string, string> = {
'ippan-situmon': '一般質問',
+ 'about-dyslexia': 'ディスレクシアについて',
'gian-tou': '議案等',
'hattatu': '発達関連',
'blog': 'ふらっとブログ',
@@ -39,20 +55,27 @@ function labelMap(segment: string): string | null {
---
{breadcrumbs.length > 0 && (
- <nav class="breadcrumbs" aria-label="パンくず">
- <ol>
- <li><a href="/">ホーム</a></li>
- {breadcrumbs.map((crumb, i) => (
- <li>
- {i < breadcrumbs.length - 1 ? (
- <a href={crumb.href}>{crumb.label}</a>
- ) : (
- <span>{crumb.label}</span>
- )}
- </li>
- ))}
- </ol>
- </nav>
+ <>
+ <script
+ type="application/ld+json"
+ is:inline
+ set:html={JSON.stringify(breadcrumbList)}
+ />
+ <nav class="breadcrumbs" aria-label="パンくず">
+ <ol>
+ <li><a href="/">ホーム</a></li>
+ {breadcrumbs.map((crumb, i) => (
+ <li>
+ {i < breadcrumbs.length - 1 ? (
+ <a href={crumb.href}>{crumb.label}</a>
+ ) : (
+ <span>{crumb.label}</span>
+ )}
+ </li>
+ ))}
+ </ol>
+ </nav>
+ </>
)}
<style>