From 9fdff03dc4ee9d0337e04ebe77298574e7c71a39 Mon Sep 17 00:00:00 2001 From: Michael Mattig Date: Wed, 17 Dec 2025 18:04:18 +0100 Subject: [PATCH 1/5] show more news --- src/components/NavBar.astro | 8 ++++ src/components/News.astro | 15 +++--- src/i18n/translations.ts | 8 ++++ src/pages/en/news.astro | 5 ++ src/pages/neuigkeiten.astro | 96 +++++++++++++++++++++++++++++++++++++ 5 files changed, 125 insertions(+), 7 deletions(-) create mode 100644 src/pages/en/news.astro create mode 100644 src/pages/neuigkeiten.astro diff --git a/src/components/NavBar.astro b/src/components/NavBar.astro index d57b670..e11973e 100644 --- a/src/components/NavBar.astro +++ b/src/components/NavBar.astro @@ -110,6 +110,14 @@ const p = useLocalePages(Astro.currentLocale); {t('data.title')} + + + {t('news.nav')} + + { const [lang, ...slug] = entry.slug.split('/'); @@ -149,13 +150,13 @@ const newsItems: Array<{ - - +
- Read more + {t('news.viewAll')} -
--> - + + diff --git a/src/i18n/translations.ts b/src/i18n/translations.ts index 23ed1ef..9fb913e 100644 --- a/src/i18n/translations.ts +++ b/src/i18n/translations.ts @@ -63,8 +63,11 @@ export const translations = { 'references.title': 'Referenzen & Beispiele', 'references.intro': 'Hier finden Sie einige Beispiele für unsere Arbeit. Diese Projekte zeigen, wie wir Geodaten und Zeitreihenverarbeitung in verschiedenen Anwendungsfällen einsetzen.', + 'news.nav': 'Neuigkeiten', 'news.title': 'Neueste Beiträge', 'news.subtitle': 'Bleiben Sie auf dem Laufenden mit unseren neuesten Nachrichten und Updates.', + 'news.allPosts': 'Alle Beiträge', + 'news.viewAll': 'Alle Beiträge anzeigen', 'footer.info': 'Informationen', 'footer.documentation': 'Dokumentation', 'footer.privacyPolicy': 'Datenschutzerklärung', @@ -146,8 +149,11 @@ export const translations = { 'references.title': 'References & Examples', 'references.intro': 'Here you will find some examples of our work. These projects show how we use geodata and time series processing in various applications.', + 'news.nav': 'News', 'news.title': 'Latest Posts', 'news.subtitle': 'Stay up to date with our latest news and updates.', + 'news.allPosts': 'All Posts', + 'news.viewAll': 'View all posts', 'footer.info': 'Information', 'footer.documentation': 'Documentation', 'footer.privacyPolicy': 'Privacy Policy', @@ -185,6 +191,7 @@ export const pages = { privacyPolicy: '/datenschutzerklaerung/', references: '/beispiele-referenzen/', services: '/services/', + news: '/neuigkeiten/', 404: '/404/', }, en: { @@ -197,6 +204,7 @@ export const pages = { privacyPolicy: '/en/privacy-policy/', references: '/en/examples-references/', services: '/en/services/', + news: '/en/news/', 404: '/en/404/', }, } as const; diff --git a/src/pages/en/news.astro b/src/pages/en/news.astro new file mode 100644 index 0000000..4791203 --- /dev/null +++ b/src/pages/en/news.astro @@ -0,0 +1,5 @@ +--- +import Page from '../neuigkeiten.astro'; +--- + + diff --git a/src/pages/neuigkeiten.astro b/src/pages/neuigkeiten.astro new file mode 100644 index 0000000..54d0719 --- /dev/null +++ b/src/pages/neuigkeiten.astro @@ -0,0 +1,96 @@ +--- +import {getCollection} from 'astro:content'; +import {asLocale, slugToPostLink, useTranslations} from '../i18n/utils'; +import {Image} from 'astro:assets'; +import {mdExcerpt, pictureWidths} from '../components/utils'; +import Section from '../components/Section.astro'; +import Layout from '../layouts/Layout.astro'; + +const t = useTranslations(Astro.currentLocale); + +const pageLang = Astro.currentLocale; + +const pages = await getCollection('posts', (entry) => { + const [lang, ...slug] = entry.slug.split('/'); + if (lang !== pageLang) { + return undefined; + } + return entry; +}); + +pages.sort((a, b) => b.data.date.getTime() - a.data.date.getTime()); + +const paths = pages.map((page) => { + const [lang, ...slug] = page.slug.split('/'); + if (slug.length === 0) { + throw new Error(`Empty slug: ${page.slug}`); + } + return {params: {lang: asLocale(lang), slug: slug.join('/')}, props: page}; +}); + +const newsItems: Array<{ + title: string; + date: string; + image: ImageMetadata; + abstract: string; + link: string; +}> = paths.map((page) => { + return { + title: page.props.data.title, + date: page.props.data.date.toLocaleDateString(pageLang, { + year: 'numeric', + month: 'long', + day: 'numeric', + }), + image: page.props.data.image, + abstract: mdExcerpt(page.props.body, 200), + link: slugToPostLink(page.params.lang, page.params.slug), + }; +}); +--- + + +
+ +
+

{t('news.allPosts')}

+

+ {t('news.subtitle')} +

+
+ + + +
+ + { + newsItems.map((news) => ( + + {news.title} +
+

+ {news.title} +

+

{news.abstract}

+
+
+
+
{news.date}
+
+
+
+ )) + } + +
+ +
+
From ea90e0c6e5b55d48b7d4b12bfb1716e205e038d3 Mon Sep 17 00:00:00 2001 From: Michael Mattig Date: Thu, 18 Dec 2025 10:33:59 +0100 Subject: [PATCH 2/5] remove news from nav --- src/components/NavBar.astro | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/components/NavBar.astro b/src/components/NavBar.astro index e11973e..d57b670 100644 --- a/src/components/NavBar.astro +++ b/src/components/NavBar.astro @@ -110,14 +110,6 @@ const p = useLocalePages(Astro.currentLocale); {t('data.title')} - - - {t('news.nav')} - - Date: Thu, 18 Dec 2025 10:36:29 +0100 Subject: [PATCH 3/5] change view all news button --- src/components/News.astro | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/components/News.astro b/src/components/News.astro index bcdca2b..14c7c77 100644 --- a/src/components/News.astro +++ b/src/components/News.astro @@ -153,22 +153,10 @@ const newsItems: Array<{ From 7418922592428ae05c71c1d37f026d002cde385b Mon Sep 17 00:00:00 2001 From: Michael Mattig Date: Thu, 18 Dec 2025 12:33:14 +0100 Subject: [PATCH 4/5] reuse news component --- src/components/News.astro | 93 ++++++++++++++++--------------------- src/pages/index.astro | 19 +++++++- src/pages/neuigkeiten.astro | 93 ++----------------------------------- 3 files changed, 63 insertions(+), 142 deletions(-) diff --git a/src/components/News.astro b/src/components/News.astro index 14c7c77..0eac3b8 100644 --- a/src/components/News.astro +++ b/src/components/News.astro @@ -4,6 +4,12 @@ import {asLocale, slugToPostLink, useTranslations, useLocalePages} from '../i18n import {Image} from 'astro:assets'; import {mdExcerpt, pictureWidths} from './utils'; +interface Props { + limit: number; +} + +const {limit} = Astro.props; + const pageLang = Astro.currentLocale; const t = useTranslations(pageLang); const p = useLocalePages(pageLang); @@ -26,7 +32,7 @@ const paths = pages } return {params: {lang: asLocale(lang), slug: slug.join('/')}, props: page}; }) - .slice(0, 3); // Limit to 3 posts + .slice(0, limit === undefined ? 3 : limit === null ? pages.length : limit); // Limit posts based on prop const newsItems: Array<{ title: string; @@ -49,43 +55,32 @@ const newsItems: Array<{ }); --- - -
- -
-

{t('news.title')}

-

- {t('news.subtitle')} -

-
- - - -
- - { - newsItems.map((news) => ( - - {news.title} -
-

{news.title}

-

{news.abstract}

-
-
+ + + + + diff --git a/src/pages/index.astro b/src/pages/index.astro index 0e15bc2..5e18653 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -121,7 +121,24 @@ const p = useLocalePages(Astro.currentLocale);

- +
+ +
+

{t('news.title')}

+

+ {t('news.subtitle')} +

+
+ + +

diff --git a/src/pages/neuigkeiten.astro b/src/pages/neuigkeiten.astro index 54d0719..baa7596 100644 --- a/src/pages/neuigkeiten.astro +++ b/src/pages/neuigkeiten.astro @@ -1,96 +1,13 @@ --- -import {getCollection} from 'astro:content'; -import {asLocale, slugToPostLink, useTranslations} from '../i18n/utils'; -import {Image} from 'astro:assets'; -import {mdExcerpt, pictureWidths} from '../components/utils'; -import Section from '../components/Section.astro'; +import {useTranslations} from '../i18n/utils'; import Layout from '../layouts/Layout.astro'; +import News from '../components/News.astro'; const t = useTranslations(Astro.currentLocale); - -const pageLang = Astro.currentLocale; - -const pages = await getCollection('posts', (entry) => { - const [lang, ...slug] = entry.slug.split('/'); - if (lang !== pageLang) { - return undefined; - } - return entry; -}); - -pages.sort((a, b) => b.data.date.getTime() - a.data.date.getTime()); - -const paths = pages.map((page) => { - const [lang, ...slug] = page.slug.split('/'); - if (slug.length === 0) { - throw new Error(`Empty slug: ${page.slug}`); - } - return {params: {lang: asLocale(lang), slug: slug.join('/')}, props: page}; -}); - -const newsItems: Array<{ - title: string; - date: string; - image: ImageMetadata; - abstract: string; - link: string; -}> = paths.map((page) => { - return { - title: page.props.data.title, - date: page.props.data.date.toLocaleDateString(pageLang, { - year: 'numeric', - month: 'long', - day: 'numeric', - }), - image: page.props.data.image, - abstract: mdExcerpt(page.props.body, 200), - link: slugToPostLink(page.params.lang, page.params.slug), - }; -}); --- -

- -
-

{t('news.allPosts')}

-

- {t('news.subtitle')} -

-
- - - -
- - { - newsItems.map((news) => ( - - {news.title} -
-

- {news.title} -

-

{news.abstract}

-
-
-
-
{news.date}
-
-
-
- )) - } - -
- -
+
+ +
From 91dd03f554cf26fdec5136fe4eb33b2859d34aa0 Mon Sep 17 00:00:00 2001 From: Michael Mattig Date: Thu, 18 Dec 2025 17:47:53 +0100 Subject: [PATCH 5/5] fix limit --- src/components/News.astro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/News.astro b/src/components/News.astro index 0eac3b8..971e52b 100644 --- a/src/components/News.astro +++ b/src/components/News.astro @@ -32,7 +32,7 @@ const paths = pages } return {params: {lang: asLocale(lang), slug: slug.join('/')}, props: page}; }) - .slice(0, limit === undefined ? 3 : limit === null ? pages.length : limit); // Limit posts based on prop + .slice(0, limit); // Limit posts based on prop const newsItems: Array<{ title: string;