diff --git a/packages/starpod/README.md b/packages/starpod/README.md index 1dc8426..9c14b2e 100644 --- a/packages/starpod/README.md +++ b/packages/starpod/README.md @@ -105,8 +105,8 @@ starpod(starpodConfig, { }); ``` -Overridable components: `Dots`, `EpisodeList`, `Hosts`, `InfoCard`, -`LargePlatforms`, `NotFoundContent`, `Platforms`, `ShowArtwork`. +Overridable components: `Breadcrumbs`, `Dots`, `EpisodeList`, `Hosts`, +`InfoCard`, `LargePlatforms`, `NotFoundContent`, `Platforms`, `ShowArtwork`. ## Custom pages diff --git a/packages/starpod/src/components/Breadcrumbs.astro b/packages/starpod/src/components/Breadcrumbs.astro index 5424bba..9cccf12 100644 --- a/packages/starpod/src/components/Breadcrumbs.astro +++ b/packages/starpod/src/components/Breadcrumbs.astro @@ -1,31 +1,42 @@ --- import { Schema } from 'astro-seo-schema'; -const { url } = Astro; - export interface Props { title: string; } const { title } = Astro.props; +const { pathname } = Astro.url; + +/** "my-cool-page" -> "My Cool Page" */ +function titleize(segment: string): string { + return decodeURIComponent(segment) + .split('-') + .map((word) => word.charAt(0).toUpperCase() + word.slice(1)) + .join(' '); +} + +// Every path segment becomes a crumb, so nested routes (e.g. a site's +// /collections/some-collection page) get intermediate crumbs linking to +// their cumulative path. The final crumb uses the page's own title. +const segments = pathname.split('/').filter(Boolean); +const crumbs = [ + { name: 'Home', href: '/' }, + ...segments.map((segment, index) => ({ + name: index === segments.length - 1 ? title : titleize(segment), + href: '/' + segments.slice(0, index + 1).join('/') + })) +]; const breadcrumbSchema = { '@context': 'https://schema.org', '@type': 'BreadcrumbList', - itemListElement: [ - { - '@type': 'ListItem', - position: 1, - name: 'Home', - item: Astro.site?.toString() || '/' - }, - { - '@type': 'ListItem', - position: 2, - name: title, - item: new URL(url, Astro.site).toString() - } - ] + itemListElement: crumbs.map((crumb, index) => ({ + '@type': 'ListItem', + position: index + 1, + name: crumb.name, + item: new URL(crumb.href, Astro.site).toString() + })) }; --- @@ -33,31 +44,40 @@ const breadcrumbSchema = { diff --git a/packages/starpod/src/index.ts b/packages/starpod/src/index.ts index 8f4f777..047bad1 100644 --- a/packages/starpod/src/index.ts +++ b/packages/starpod/src/index.ts @@ -22,6 +22,7 @@ import { * module everywhere at once. */ const OVERRIDABLE_COMPONENTS = { + Breadcrumbs: './components/Breadcrumbs.astro', Dots: './components/Dots.astro', EpisodeList: './components/EpisodeList.astro', Hosts: './components/Hosts.astro', diff --git a/packages/starpod/src/layouts/Layout.astro b/packages/starpod/src/layouts/Layout.astro index ba36cc0..8ada5b8 100644 --- a/packages/starpod/src/layouts/Layout.astro +++ b/packages/starpod/src/layouts/Layout.astro @@ -5,7 +5,7 @@ import { Schema } from 'astro-seo-schema'; import SpeedInsights from '@vercel/speed-insights/astro'; -import Breadcrumbs from '../components/Breadcrumbs.astro'; +import Breadcrumbs from 'virtual:starpod/components/Breadcrumbs'; import Dots from 'virtual:starpod/components/Dots'; import Hosts from 'virtual:starpod/components/Hosts'; import InfoCard from 'virtual:starpod/components/InfoCard'; @@ -67,8 +67,6 @@ const description = Astro.props.description ?? starpodConfig.description; - - - - - - - #da532c - - - diff --git a/public/mstile-150x150.png b/public/mstile-150x150.png deleted file mode 100644 index d81d0d0..0000000 Binary files a/public/mstile-150x150.png and /dev/null differ diff --git a/public/safari-pinned-tab.svg b/public/safari-pinned-tab.svg deleted file mode 100644 index 5e5f081..0000000 --- a/public/safari-pinned-tab.svg +++ /dev/null @@ -1,26 +0,0 @@ - - - - -Created by potrace 1.14, written by Peter Selinger 2001-2017 - - - - - - -