summaryrefslogtreecommitdiff
path: root/src/components/NewsPreviewLink.astro
blob: 566f1367cbdeea62eb64668a0d64de50eff8164a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
---
import translate from '$i18n/translate';
import tNewsPreviewLink from '$i18n/translations/components/newsPreviewLink';
import getLocaleFromPath from '$lib/getLocaleFromPath';
import type { CollectionEntry } from 'astro:content';

interface Props {
  newsItem: CollectionEntry<'news'>;
}

const { newsItem } = Astro.props;
const locale = getLocaleFromPath(Astro.url.pathname);
const t = translate(locale);
---

<a class="news-index__item" href={`/${locale}/news/${newsItem.slug.replace('/', '-')}`}>
  <h2>{newsItem.data.title}</h2>
  <p>{newsItem.data.summary}</p>
  <p class="link">{t(tNewsPreviewLink, { key: 'read-article' })}</p>
</a>