diff --git a/gatsby-node.ts b/gatsby-node.ts index d3dbbe6c3..a0833581e 100644 --- a/gatsby-node.ts +++ b/gatsby-node.ts @@ -292,6 +292,11 @@ export const createPages: GatsbyNode['createPages'] = async ({ graphql, actions component: path.resolve('src', 'components', 'Banner', 'index.tsx'), }) + createSlice({ + id: 'adoptiumNews', + component: path.resolve('src', 'components', 'AdoptiumNews', 'index.tsx'), + }) + // create slice for AuthorBio for (const author of Object.keys(authors)) { createSlice({ diff --git a/src/components/AdoptiumNews/__tests__/adoptiumNews.test.tsx b/src/components/AdoptiumNews/__tests__/adoptiumNews.test.tsx new file mode 100644 index 000000000..0be3f629e --- /dev/null +++ b/src/components/AdoptiumNews/__tests__/adoptiumNews.test.tsx @@ -0,0 +1,12 @@ +import React from 'react'; +import { render } from '@testing-library/react'; +import { describe, expect, it } from 'vitest' +import AdoptiumNews from '..'; + +describe('AdoptiumNews component', () => { + it('renders correctly', () => { + const { container } = render(); + // expect container to either be null or contain a div with the class of alert + expect(container).toBeNull || expect(container.querySelector('div.text-pink')).toBeTruthy(); + }); +}); diff --git a/src/components/AdoptiumNews/index.tsx b/src/components/AdoptiumNews/index.tsx new file mode 100644 index 000000000..98fcbe7b1 --- /dev/null +++ b/src/components/AdoptiumNews/index.tsx @@ -0,0 +1,53 @@ +import React from 'react'; +import moment from 'moment'; +import { Trans } from 'gatsby-plugin-react-i18next'; +import LinkText from '../LinkText' + +const AdoptiumNews = () => { + + // 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-05-15'), + stopDisplayAfter: new Date('2024-06-30'), + } + + const now = Date.now(); + if(!adoptiumNews || now < adoptiumNews.startDisplayAt.getTime() || now > adoptiumNews.stopDisplayAfter.getTime()) return; + + return ( +
+
+

{adoptiumNews.title}

+
+ {adoptiumNews.date &&

{moment(adoptiumNews.date).format('D MMMM YYYY')}

} +

+ + }} + /> +

+
+
+
+ ); +}; + +export default AdoptiumNews; + +export interface AdoptiumNewsItem { + title: string; + body: string; + date?: Date; + callToActionLink?: string; + startDisplayAt: Date; + stopDisplayAfter: Date; +} diff --git a/src/pages/__tests__/__snapshots__/index.test.tsx.snap b/src/pages/__tests__/__snapshots__/index.test.tsx.snap index 7d6a8e91e..07bca0a0d 100644 --- a/src/pages/__tests__/__snapshots__/index.test.tsx.snap +++ b/src/pages/__tests__/__snapshots__/index.test.tsx.snap @@ -126,6 +126,9 @@ exports[`Index page > renders correctly 1`] = ` +
diff --git a/src/pages/index.tsx b/src/pages/index.tsx index c88ddf360..64e3f2da2 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -6,6 +6,8 @@ import { StaticImage } from 'gatsby-plugin-image' import Layout from '../components/Layout' import Seo from '../components/Seo' import LatestTemurin from '../components/LatestTemurin' +import AdoptiumNews from '../components/AdoptiumNews' +import { Slice } from 'gatsby' const IndexPage = ({data}) => { const latestLTS = data.mostRecentLts.version @@ -43,6 +45,7 @@ const IndexPage = ({data}) => {
+

The Adoptium® Working Group