diff options
Diffstat (limited to 'src/components/NewsIndex/NewsPreviewLink.astro')
| -rw-r--r-- | src/components/NewsIndex/NewsPreviewLink.astro | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/components/NewsIndex/NewsPreviewLink.astro b/src/components/NewsIndex/NewsPreviewLink.astro new file mode 100644 index 0000000..aa8a371 --- /dev/null +++ b/src/components/NewsIndex/NewsPreviewLink.astro @@ -0,0 +1,25 @@ +--- +import translate from '$i18n/translate'; +import tComponent from '$i18n/translations/components/newsIndex'; +import getLocaleFromPath from '$lib/getLocaleFromPath'; +import type { CollectionEntry } from 'astro:content'; + +interface Props { + headingLevel: 'h1' | 'h2' | 'h3' | 'h4'; + newsItem: CollectionEntry<'news'>; +} + +const { headingLevel, newsItem } = Astro.props; +const locale = getLocaleFromPath(Astro.url.pathname); +const t = translate(locale); +--- + +<a class="news-index__item group-hover" href={`/${locale}/news/${newsItem.slug.replace('/', '-')}`}> + <Fragment + set:html={` + <${headingLevel}>${newsItem.data.title}</${headingLevel}> + `} + /> + <p>{newsItem.data.summary}</p> + <p class="link">{t(tComponent, { key: 'read-article' })}</p> +</a> |
