--- import config from 'virtual:starlight/user-config'; const route = Astro.locals.starlightRoute; const base = config.base || ''; const slug = route.entry?.slug || route.id || ''; const parts = slug.split('/').filter(Boolean); // Build breadcrumb trail const breadcrumbs: { label: string; href: string }[] = []; let currentPath = ''; for (let i = 0; i < parts.length; i++) { currentPath += '/' + parts[i]; breadcrumbs.push({ label: labelMap(parts[i]) || parts[i], href: base + currentPath + '/', }); } // Replace last breadcrumb label with page title 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 = { 'ippan-situmon': '一般質問', 'iinkai': '委員会・請願', 'media': 'メディア掲載', 'about-dyslexia': 'ディスレクシアについて', 'gian-tou': '議案等', 'hattatu': '発達関連', 'blog': 'ふらっとブログ', 'r8d': '令和8年度', 'r7d': '令和7年度', 'r6d': '令和6年度', 'r5d': '令和5年度', 'r4d': '令和4年度', 'r3d': '令和3年度', 'r2d': '令和2年度', 'r1d': '令和元年度', '6gatu': '6月定例会', '9gatu': '9月定例会', '12gatu': '12月定例会', '3gatu': '3月定例会', }; return map[segment] || null; } --- {breadcrumbs.length > 0 && ( <>