diff --git a/src/components/FrontCard.astro b/src/components/FrontCard.astro new file mode 100644 index 0000000..3655307 --- /dev/null +++ b/src/components/FrontCard.astro @@ -0,0 +1,279 @@ +--- +interface Props { + kind: string; + title: string; + description: string; + href: string; + date?: Date; + meta?: string; + image?: string; + imageAlt?: string; + size?: 'lead' | 'side' | 'wide' | 'standard' | 'compact'; + tone?: 'paper' | 'blue' | 'ink' | 'soft' | 'amend'; +} + +const { + kind, + title, + description, + href, + date, + meta, + image, + imageAlt = '', + size = 'standard', + tone = 'paper', +} = Astro.props; + +const formattedDate = date + ? new Intl.DateTimeFormat('en-GB', { + day: 'numeric', + month: 'short', + year: 'numeric', + }).format(date) + : ''; +--- + +
+ + {image && ( +
+ {imageAlt} +
+ )} +
+
+ {kind} + {date && } +
+
+

{title}

+

{description}

+
+ {meta && } +
+
+
+ + diff --git a/src/components/Header.astro b/src/components/Header.astro index 485fb4f..a624cd0 100644 --- a/src/components/Header.astro +++ b/src/components/Header.astro @@ -1,19 +1,33 @@ --- +import { getCollection } from 'astro:content'; import { navigation, site } from '../site.config'; + +const [stories, briefings, episodes, guides] = await Promise.all([ + getCollection('stories', ({ data }) => !data.draft), + getCollection('briefings', ({ data }) => !data.draft), + getCollection('episodes', ({ data }) => !data.draft), + getCollection('guides', ({ data }) => !data.draft), +]); + +const visibleNavigation = navigation.filter((item) => { + if (item.href === '/stories') return stories.length > 0; + if (item.href === '/briefing') return briefings.length > 0; + if (item.href === '/podcast') return episodes.length > 0; + if (item.href === '/guides') return guides.length > 0; + if (item.href === '/book') return site.book.enabled; + return true; +}); ---