From 869976b711d862581d1d99bf884dd166b1ecdf3b Mon Sep 17 00:00:00 2001 From: Joe Carstairs <65492573+Sycamost@users.noreply.github.com> Date: Sun, 20 Aug 2023 07:57:21 +0100 Subject: Pulls out NewsIndex Astro component --- src/components/NewsIndex/NewsIndex.astro | 25 +++++++++++++++++++++++++ src/components/NewsIndex/NewsPreviewLink.astro | 25 +++++++++++++++++++++++++ src/components/NewsPreviewLink.astro | 25 ------------------------- 3 files changed, 50 insertions(+), 25 deletions(-) create mode 100644 src/components/NewsIndex/NewsIndex.astro create mode 100644 src/components/NewsIndex/NewsPreviewLink.astro delete mode 100644 src/components/NewsPreviewLink.astro (limited to 'src/components') diff --git a/src/components/NewsIndex/NewsIndex.astro b/src/components/NewsIndex/NewsIndex.astro new file mode 100644 index 0000000..6738071 --- /dev/null +++ b/src/components/NewsIndex/NewsIndex.astro @@ -0,0 +1,25 @@ +--- +import type { CollectionEntry } from 'astro:content'; +import NewsPreviewLink from './NewsPreviewLink.astro'; +import getLocaleFromPath from '$lib/getLocaleFromPath'; +import translate from '$i18n/translate'; +import tComponent from '$i18n/translations/components/newsIndex'; +interface Props { + headingLevel: 'h2' | 'h3' | 'h4'; + newsItems: CollectionEntry<'news'>[]; +} + +const { headingLevel, newsItems } = Astro.props; +const locale = getLocaleFromPath(Astro.url.pathname); +const t = translate(locale); +--- + +
{t(tComponent, { key: 'no-news' })}
+ ) + } +{newsItem.data.summary}
+{t(tComponent, { key: 'read-article' })}
+{newsItem.data.summary}
-{t(tNewsPreviewLink, { key: 'read-article' })}
-