summaryrefslogtreecommitdiff
path: root/src/components/NewsIndex/NewsPreviewLink.astro
blob: fa01d8d570ab2048d9f9e725c8e86551d644ac9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
---
import translate from '$i18n/translate';
import tComponent from '$i18n/translations/components/newsIndex';
import { getLocaleFromPathOrThrow } from '$lib/getLocaleFromPath';
import { getHref } from '$lib/newsUtils';
import type { CollectionEntry } from 'astro:content';

interface Props {
  headingLevel: 'h1' | 'h2' | 'h3' | 'h4';
  newsItem: CollectionEntry<'news'>;
}

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

<a class="news-index__item group-hover" href={getHref(newsItem)}>
  <Fragment
    set:html={`
    <${headingLevel}>${newsItem.data.title}</${headingLevel}>
  `}
  />
  <p>{newsItem.data.summary}</p>
  <p class="link">{t(tComponent, { key: 'read-article' })}</p>
</a>