diff --git a/src/components/AdoptiumNews/index.tsx b/src/components/AdoptiumNews/index.tsx
index c01c27a2f..fe312e270 100644
--- a/src/components/AdoptiumNews/index.tsx
+++ b/src/components/AdoptiumNews/index.tsx
@@ -5,14 +5,24 @@ import LinkText from '../LinkText'
// NOTES:
// - You can add a tag to create a link in the body
// - Dates must be with the format: "YYYY-MM-dd"
-const adoptiumNews = {
- title: "Adoptium Summit 2024",
- body: "Be a part of the first-ever Adoptium Summit on September, 10.
Connect with peers to exchange knowledge on Temurin, AQAvit and other Adoptium's projects.
Register here",
- callToActionLink: 'https://www.eclipse.org/events/2024/adoptium-summit/',
- date: new Date('2024-09-10'),
- startDisplayAt: new Date('2024-08-01'),
- stopDisplayAfter: new Date('2024-09-09'),
-}
+const adoptiumNewsList = [
+ {
+ title: "Adoptium Summit 2024",
+ body: "Be a part of the first-ever Adoptium Summit on September, 10.
Connect with peers to exchange knowledge on Temurin, AQAvit and other Adoptium's projects.
Register here",
+ callToActionLink: 'https://www.eclipse.org/events/2024/adoptium-summit/',
+ date: new Date('2024-09-10'),
+ startDisplayAt: new Date('2024-08-01'),
+ stopDisplayAfter: new Date('2024-09-10'),
+ },
+ {
+ title: "Adoptium Summit 2024",
+ body: "Join us Today for the first-ever Adoptium Summit.
An opportunity to connect with other Adoptium community members.
Register here",
+ callToActionLink: 'https://www.eclipse.org/events/2024/adoptium-summit/',
+ date: new Date('2024-09-10'),
+ startDisplayAt: new Date('2024-09-10'),
+ stopDisplayAfter: new Date('2024-09-11'),
+ }
+]
const eventDateOptions = {
year: 'numeric',
@@ -21,42 +31,50 @@ const eventDateOptions = {
timeZone: "UTC"
}
+function compareNewsByStartDisplayAt(a: AdoptiumNewsItem, b: AdoptiumNewsItem) {
+ return a.startDisplayAt.getTime() - b.startDisplayAt.getTime();
+}
+
const AdoptiumNews = () => {
const { language } = useI18next();
- var eventDateUTC:Date|null = null;
- if(adoptiumNews.date) {
- eventDateUTC = new Date(Date.UTC(
- adoptiumNews.date.getUTCFullYear(),
- adoptiumNews.date.getUTCMonth(),
- adoptiumNews.date.getUTCDate(),
- adoptiumNews.date.getUTCHours(),
- adoptiumNews.date.getUTCMinutes(),
- adoptiumNews.date.getUTCSeconds()));
-
- }
-
const now = Date.now();
- if(!adoptiumNews || now < adoptiumNews.startDisplayAt.getTime() || now > adoptiumNews.stopDisplayAfter.getTime()) return;
return (
-
-
-
{adoptiumNews.title}
-
- {eventDateUTC &&
{(eventDateUTC.toLocaleDateString(language, eventDateOptions))}
}
-
-
- }}
- />
-
-
-
-
+ adoptiumNewsList
+ .filter(adoptiumNews => adoptiumNews.startDisplayAt.getTime() <= now && adoptiumNews.stopDisplayAfter.getTime() > now)
+ .sort(compareNewsByStartDisplayAt)
+ .map((adoptiumNews, index) => {
+ var eventDateUTC:Date|null = null;
+ if(adoptiumNews.date) {
+ eventDateUTC = new Date(Date.UTC(
+ adoptiumNews.date.getUTCFullYear(),
+ adoptiumNews.date.getUTCMonth(),
+ adoptiumNews.date.getUTCDate(),
+ adoptiumNews.date.getUTCHours(),
+ adoptiumNews.date.getUTCMinutes(),
+ adoptiumNews.date.getUTCSeconds()));
+ }
+
+ return (
+
+
+
{adoptiumNews.title}
+
+ {eventDateUTC &&
{(eventDateUTC.toLocaleDateString(language, eventDateOptions))}
}
+
+
+ }}
+ />
+
+
+
+
)
+ })
);
};