|
| 1 | +// SPDX-FileCopyrightText: 2024 Dusan Mijatovic (Netherlands eScience Center) |
| 2 | +// SPDX-FileCopyrightText: 2024 Netherlands eScience Center |
| 3 | +// |
| 4 | +// SPDX-License-Identifier: Apache-2.0 |
| 5 | + |
| 6 | +import Link from 'next/link' |
| 7 | +import {TopNewsProps} from '~/components/news/apiNews' |
| 8 | +import GradientBorderButton from './GradientBorderButton' |
| 9 | +import {config} from './config' |
| 10 | +import HomepageDivider from './HomepageDivider' |
| 11 | + |
| 12 | +const {button} = config |
| 13 | + |
| 14 | +function TopNewsItem({item}:{item:TopNewsProps}){ |
| 15 | + return ( |
| 16 | + <Link |
| 17 | + href={`/news/${item.publication_date}/${item.slug}`} |
| 18 | + > |
| 19 | + <article className="flex gap-4 items-start" data-aos="fade" data-aos-delay="0"> |
| 20 | + {/* <LandingPageImpactIcon className="h-auto mr-5 pt-1 scale-125 flex-shrink-0" /> */} |
| 21 | + <div> |
| 22 | + <h3 className="mb-4 text-2xl font-medium">{item.title}</h3> |
| 23 | + <p className="text-lg opacity-70">{item.summary}</p> |
| 24 | + </div> |
| 25 | + |
| 26 | + </article> |
| 27 | + </Link> |
| 28 | + ) |
| 29 | +} |
| 30 | +/** |
| 31 | + * Top news items including the homepage divider. |
| 32 | + * If there are no news items it returns null. |
| 33 | + * */ |
| 34 | +export default function TopNewsSection({news}:{news:TopNewsProps[]}) { |
| 35 | + |
| 36 | + // console.group('TopNewsSection') |
| 37 | + // console.log('news...',news) |
| 38 | + // console.groupEnd() |
| 39 | + |
| 40 | + if (news?.length > 0){ |
| 41 | + return ( |
| 42 | + <> |
| 43 | + <section |
| 44 | + id="top-news" |
| 45 | + className="p-5 md:p-10 w-full max-w-screen-xl mx-auto"> |
| 46 | + |
| 47 | + <h2 className="flex justify-start text-3xl lg:text-4xl font-rsd-titles font-bold mt-6" |
| 48 | + data-aos="fade" data-aos-duration="400" data-aos-easing="ease-in-out"> |
| 49 | + Latest news |
| 50 | + </h2> |
| 51 | + |
| 52 | + <div className="grid gap-20 grid-cols-1 md:grid-cols-2 pt-14"> |
| 53 | + {news.map(item=>{ |
| 54 | + return <TopNewsItem key={item.id} item={item} /> |
| 55 | + })} |
| 56 | + <div className="flex justify-center items-center" |
| 57 | + data-aos="fade" |
| 58 | + data-aos-easing="ease-in-out" |
| 59 | + data-aos-duration="500" |
| 60 | + > |
| 61 | + <GradientBorderButton |
| 62 | + text={button.news.label} |
| 63 | + url={button.news.url} |
| 64 | + target={button.news.target} |
| 65 | + /> |
| 66 | + </div> |
| 67 | + </div> |
| 68 | + </section> |
| 69 | + <HomepageDivider /> |
| 70 | + </> |
| 71 | + ) |
| 72 | + } |
| 73 | + return null |
| 74 | +} |
0 commit comments