Skip to content

Commit

Permalink
add news homepage
Browse files Browse the repository at this point in the history
  • Loading branch information
gdams committed Jan 22, 2025
1 parent 1225b26 commit c52d917
Show file tree
Hide file tree
Showing 17 changed files with 533 additions and 1,069 deletions.
8 changes: 4 additions & 4 deletions gatsby-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ export const createPages: GatsbyNode["createPages"] = async ({
actions,
}) => {
const { createPage, createSlice } = actions
const postsPerPage = 10
const postsPerPage = 6

// Create Slice components https://www.gatsbyjs.com/docs/how-to/performance/using-slices/
createSlice({
Expand Down Expand Up @@ -602,7 +602,7 @@ export const createPages: GatsbyNode["createPages"] = async ({
// Make tag pages
tags.forEach(tag => {
createPage({
path: `/blog/tags/${tag.fieldValue}/`,
path: `/news/tags/${tag.fieldValue}/`,
component: tagTemplate,
context: {
tag: tag.fieldValue,
Expand All @@ -619,8 +619,8 @@ export const createPages: GatsbyNode["createPages"] = async ({
currentPageNumber === numPages ? null : currentPageNumber + 1

createPage({
path: `/blog/page/${index + 1}`,
component: path.resolve("./src/templates/blogPage.tsx"),
path: `/news/page/${index + 1}`,
component: path.resolve("./src/templates/newsPage.tsx"),
context: {
limit: postsPerPage,
skip: index * postsPerPage,
Expand Down
29 changes: 29 additions & 0 deletions src/components/Events/EventCard/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from "react"
import { Link } from "gatsby-plugin-react-i18next"

const EventCard = ({ post }) => {
return (
<div className=" flex flex-col max-w-[385px] newscard-2 bg-[#200D46] ">
<img className="mb-0" src="/images/new-article-card-img.png" alt="" />
<div className="p-8">
<h3 className="text-[24px] font-semibold leading-[133.333%]">
{post.node.frontmatter.title}
</h3>
<div className="flex justify-between pt-4">
<h3 className="flex flex-col gap-1 tab-button-text text-white">
<span>{post.node.frontmatter.date}</span>
{/* <span>London</span> */}
</h3>
{/* <h3 className="tab-button-text text-white">13:00 - 15:00</h3> */}
</div>
<Link to={post.node.fields.postPath}>
<button className="rounded-2xl bg-transparent gradient-border mt-10 border-2 border-pink-500/0 text-white text-base leading-6 font-bold w-[160px] h-[48px] block ">
Read More
</button>
</Link>
</div>
</div>
)
}

export default EventCard
2 changes: 1 addition & 1 deletion src/components/NavBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const navigation: NavItem[] = [
children: [
{ name: "Our Community", href: "#" },
{ name: "Support", href: "/support" },
{ name: "News & Updates", href: "#" },
{ name: "News & Updates", href: "/news" },
{ name: "Events", href: "#" },
],
},
Expand Down
48 changes: 48 additions & 0 deletions src/components/News/NewsCardList/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import React from "react"
import { FaChevronLeft, FaChevronRight } from "react-icons/fa";
import { Link } from "gatsby-plugin-react-i18next"

import EventCard from "../../Events/EventCard"

const NewsCardList = ({ posts, previousPageNumber, previousPageLink, nextPageNumber }) => {
const data1 = posts.slice(0, 3)
const data2 = posts.slice(3, 6)
return (
<div className="max-w-[1264px] mx-auto px-6 py-8 md:pt-12">
<div className="flex justify-center gap-6 items-center flex-wrap pt-8 md:pt-12">
{data1.map((post, index) => (
<EventCard key={index} post={post} />
))}
</div>
<div className="flex justify-center gap-6 items-center flex-wrap py-8 md:py-12">
{data2.map((post, index) => (
<EventCard key={index} post={post} />

Check warning on line 19 in src/components/News/NewsCardList/index.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/News/NewsCardList/index.tsx#L19

Added line #L19 was not covered by tests
))}
</div>
<div className="flex justify-center items-center gap-8 md:gap-14">
{previousPageNumber && (
<Link to={previousPageLink} rel="prev">
<div className="flex items-center gap-3">
<span className="cursor-pointer">
<FaChevronLeft />
</span>
<p className="tab-button-text mb-0 hidden md:block">Previous Page</p>
</div>
</Link>
)}
{nextPageNumber && (
<Link to={`/news/page/${nextPageNumber}`} rel="next">
<div className="flex items-center gap-3">
<p className="tab-button-text mb-0 hidden md:block">Next Page</p>
<span className="cursor-pointer">
<FaChevronRight />
</span>
</div>
</Link>
)}
</div>
</div>
)
}

export default NewsCardList
9 changes: 6 additions & 3 deletions src/components/News/RelatedArticles/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react"
import { graphql, useStaticQuery } from "gatsby"
import { Link } from "gatsby-plugin-react-i18next"
import RelatedArticleCard from "./RelatedArticleCard"

const RelatedArticle = () => {
Expand Down Expand Up @@ -32,9 +33,11 @@ const RelatedArticle = () => {
Java runtime binaries that are enterprise-ready and Java SE TCK-tested
for general use in the Java ecosystem.
</div>
<button className="rounded-2xl bg-transparent gradient-border mt-10 border-2 border-pink-500/0 text-white text-base leading-6 font-bold w-[160px] h-[48px] block ">
See all articles
</button>
<Link to="/news">
<button className="rounded-2xl bg-transparent gradient-border mt-10 border-2 border-pink-500/0 text-white text-base leading-6 font-bold w-[160px] h-[48px] block ">
See all articles
</button>
</Link>
</div>

<div className="flex justify-center flex-wrap items-center gap-5 pt-16">
Expand Down
171 changes: 113 additions & 58 deletions src/pages/__tests__/__snapshots__/blog.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,77 +1,132 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`Blog page > renders correctly 1`] = `
exports[`News page > renders correctly 1`] = `
<main>
<section
class="py-5 container"
<div
class="relative pt-40 pb-16 md:pb-36 md:pt-60 overflow-hidden"
>
<div
class="row py-lg-5"
class="w-full relative"
>
<div
class="col-lg-9 col-md-9 mx-auto"
class="absolute z-[-1] w-[2396px] h-[1340px] left-[23px] md:left-[112px] top-[21px] md:top-[171px] bg-[#410170] shadow-[0_0_400px_rgba(65,1,112,1)] rounded-full blur-[400px]"
/>
<div
class="absolute z-[-1] w-[1487px] h-[893px] left-[120px] md:left-[676px] top-[120px] md:top-[395px] bg-[#B62987] shadow-[0_0_400px_rgba(182,41,135,1)] rounded-full blur-[400px]"
/>
<div
class="absolute z-[-1] w-[688px] h-[446px] left-[400px] md:left-[1131px] top-[618px] bg-[#FE8492] shadow-[0_0_400px_rgba(254,132,146,1)] rounded-full blur-[400px]"
/>
</div>
<div
class="mx-auto max-w-[1048px] w-full px-6 lg:px-0 flex flex-col items-center justify-center"
>
<div
class="self-stretch flex-col justify-center items-center gap-6 flex"
>
<article
class="pb-3"
<div
class="self-stretch flex-col justify-center items-center gap-4 flex"
>
<header>
<h2
class="h3"
<div
class="justify-start items-center gap-3 inline-flex"
>
<svg
fill="none"
height="14"
viewBox="0 0 14 14"
width="14"
xmlns="http://www.w3.org/2000/svg"
>
<a
href="/mdx/mdx-page-title"
>
MDX Page title
</a>
</h2>
<rect
fill="#FF1464"
height="8"
rx="2"
width="8"
x="3"
y="3"
/>
<rect
height="11"
rx="3.5"
stroke="#FF1464"
stroke-opacity="0.25"
stroke-width="3"
width="11"
x="1.5"
y="1.5"
/>
</svg>
<div
class="flex justify-center items-center gap-5"
class="text-rose-600 text-base font-bold leading-normal"
>
<img
alt="Adoptium PMC"
image="[object Object]"
stlye="[object Object]"
style="margin-left: 0.5rem; margin-bottom: 0px; min-width: 30px; border-radius: 100%;"
/>
<span
class="text-[16px] font-bold leading-[150%] text-white"
>
<a
href="/blog/author/pmc"
>
<span
class="text-primary pr-2"
>
Adoptium PMC
,
</span>
2021-01-01
</a>
</span>
News
</div>
</header>
<section>
<p>
MDX Page excerpt
<a
href="/mdx/mdx-page-title"
>
Read more
</a>
</p>
</section>
</article>
<div>
<ul
style="display: flex; flex-wrap: wrap; justify-content: space-between; flex-direction: row-reverse; list-style: none; padding: 0px;"
</div>
<div
class="self-stretch text-center text-white text-[56px] lg:text-[80px] leading-[114.286%] md:leading-[120%] font-semibold"
>
News & Updates
</div>
</div>
<div
class="self-stretch text-center text-lightgrey text-[20px] font-normal leading-[140%] mx-auto max-w-[860px] px-2 w-full"
>
Eclipse Temurin offers high-performance, cross-platform, open-source Java runtime binaries that are enterprise-ready and Java SE TCK-tested for general use in the Java ecosystem.
</div>
</div>
</div>
</div>
<div
class="max-w-[1264px] mx-auto px-6 py-8 md:pt-12"
>
<div
class="flex justify-center gap-6 items-center flex-wrap pt-8 md:pt-12"
>
<div
class=" flex flex-col max-w-[385px] newscard-2 bg-[#200D46] "
>
<img
alt=""
class="mb-0"
src="/images/new-article-card-img.png"
/>
<div
class="p-8"
>
<h3
class="text-[24px] font-semibold leading-[133.333%]"
>
<li />
</ul>
MDX Page title
</h3>
<div
class="flex justify-between pt-4"
>
<h3
class="flex flex-col gap-1 tab-button-text text-white"
>
<span>
2021-01-01
</span>
</h3>
</div>
<a
href="/mdx/mdx-page-title"
>
<button
class="rounded-2xl bg-transparent gradient-border mt-10 border-2 border-pink-500/0 text-white text-base leading-6 font-bold w-[160px] h-[48px] block "
>
Read More
</button>
</a>
</div>
</div>
</div>
</section>
<div
class="flex justify-center gap-6 items-center flex-wrap py-8 md:py-12"
/>
<div
class="flex justify-center items-center gap-8 md:gap-14"
/>
</div>
</main>
`;
Loading

0 comments on commit c52d917

Please sign in to comment.