diff options
| author | Joe Carstairs <jcarstairs@scottlogic.com> | 2023-08-15 19:19:51 +0100 |
|---|---|---|
| committer | Joe Carstairs <jcarstairs@scottlogic.com> | 2023-08-15 19:19:51 +0100 |
| commit | 8dd3185b2548c83dbf31324452b3b410408ab4dd (patch) | |
| tree | f8ed40b554f06b324a599fb8a40bf3d12b5456ff /src/components | |
| parent | 53f29bac911b13b2bef0125de22773bf26ce5a90 (diff) | |
Parametrises heading level in NewsPreviewLink
Diffstat (limited to 'src/components')
| -rw-r--r-- | src/components/NewsPreviewLink.astro | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/components/NewsPreviewLink.astro b/src/components/NewsPreviewLink.astro index 566f136..8486fe7 100644 --- a/src/components/NewsPreviewLink.astro +++ b/src/components/NewsPreviewLink.astro @@ -5,16 +5,21 @@ import getLocaleFromPath from '$lib/getLocaleFromPath'; import type { CollectionEntry } from 'astro:content'; interface Props { + headingLevel: 'h1' | 'h2' | 'h3' | 'h4'; newsItem: CollectionEntry<'news'>; } -const { newsItem } = Astro.props; +const { headingLevel, 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> + <Fragment + set:html={` + <${headingLevel}>${newsItem.data.title}</${headingLevel}> + `} + /> <p>{newsItem.data.summary}</p> <p class="link">{t(tNewsPreviewLink, { key: 'read-article' })}</p> </a> |
