blob: 5b8153cec21aaa86495568a1ab318f0fcb8b57c5 (
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
27
28
29
30
31
32
33
34
35
36
37
|
---
import translate from '$i18n/translate';
import tComponent from '$i18n/translations/components/newsIndex';
import { getLocaleFromPathOrThrow } from '$lib/getLocaleFromPath';
import { getDate, 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);
const publicationDate = getDate(newsItem);
---
<a class="news-index__item group-hover" href={getHref(newsItem)}>
<Fragment
set:html={`
<${headingLevel}>${newsItem.data.title}</${headingLevel}>
`}
/>
<p>{newsItem.data.summary}</p>
<time datetime={publicationDate?.toISOString()}>
{
publicationDate?.toLocaleDateString('en-GB', {
day: 'numeric',
month: 'short',
year: 'numeric',
})
}
</time>
<p class="link">{t(tComponent, { key: 'read-article' })}</p>
</a>
|