Skip to content

Commit

Permalink
improve blog template (#711)
Browse files Browse the repository at this point in the history
* improve blog template

* show live data in releated articles

* add news homepage
  • Loading branch information
gdams authored Jan 22, 2025
1 parent 05f906b commit 0b8a546
Show file tree
Hide file tree
Showing 31 changed files with 1,483 additions and 1,440 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
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,30 @@ exports[`ArticlePreview component > should render correctly 1`] = `
</a>
</h2>
<div
class="byline"
style="display: flex; align-items: center; margin-top: 1rem; margin-bottom: 1rem; text-decoration: none;"
class="flex justify-center items-center gap-5"
>
2021-01-01
– posted by  
<a
href="/blog/author/pmc"
>
Adoptium PMC
</a>
<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>
</div>
</header>
<section>
Expand Down Expand Up @@ -66,17 +73,24 @@ exports[`ArticlePreview component > should render correctly no match 1`] = `
</a>
</h2>
<div
class="byline"
style="display: flex; align-items: center; margin-top: 1rem; margin-bottom: 1rem; text-decoration: none;"
class="flex justify-center items-center gap-5"
>
2021-01-01
– posted by  
<a
href="/blog/author/foo"
<span
class="text-[16px] font-bold leading-[150%] text-white"
>
Test Author
</a>
<a
href="/blog/author/foo"
>
<span
class="text-primary pr-2"
>
Test Author
,
</span>
2021-01-01
</a>
</span>
</div>
</header>
<section>
Expand Down
2 changes: 1 addition & 1 deletion src/components/ArticlePreview/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react"
import { Link } from "gatsby-plugin-react-i18next"

import Byline from "../Byline"
import Byline from "../News/Byline"

/**
* Article intro displayed on front page, archive, author page.
Expand Down
6 changes: 0 additions & 6 deletions src/components/Byline/Byline.scss

This file was deleted.

28 changes: 0 additions & 28 deletions src/components/Byline/index.tsx

This file was deleted.

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
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,30 @@
exports[`Byline component > should render correctly 1`] = `
<div>
<div
class="byline"
style="display: flex; align-items: center; margin-top: 1rem; margin-bottom: 1rem; text-decoration: none;"
class="flex justify-center items-center gap-5"
>
2021-07-01
– posted by  
<a
href="/blog/author/pmc"
>
Adoptium PMC
</a>
<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-07-01
</a>
</span>
</div>
</div>
`;
20 changes: 20 additions & 0 deletions src/components/News/Byline/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from "react"
import { Link } from "gatsby-plugin-react-i18next"
import ProfilePicInline from "../../ProfilePicInline"

const Byline = props => {
const { author, date, identifier } = props

const href = `/blog/author/${identifier}`

return (
<div className="flex justify-center items-center gap-5">
<ProfilePicInline identifier={identifier} name={author} />
<span className="text-[16px] font-bold leading-[150%] text-white">
<Link to={href}><span className="text-primary pr-2">{author},</span> {date}</Link>
</span>
</div>
)
}

export default Byline
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} />
))}
</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
30 changes: 30 additions & 0 deletions src/components/News/RelatedArticles/RelatedArticleCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from "react"
import { Link } from "gatsby"
import { capitalize } from "../../../util/capitalize"

const RelatedArticleCard = ({title, date, postPath, tags}) => {
return (
<div className="flex flex-col max-w-[392px] newscard-2 bg-[#200D46] p-6">
<div className="relative">
<img className=" mb-0 pb-5" src="/images/new-article-card-img.png" alt="" />
{tags && tags.length > 0 && (
<button className="text-[12px] font-semibold leading-[33.333%] bg-[#3E3355] rounded-[80px] px-4 py-4 absolute top-3 right-4">
{capitalize(tags[0])}
</button>
)}
</div>
<h2 className="text-[20px] font-semibold text-white leading-[140%] mb-0 pb-5">
{title}{" "}
</h2>
<p className="mb-0">{date}</p>
<Link
to={postPath}
className="py-3 text-base underline font-bold leading-6 text-white mt-4 block border-white w-fit"
>
Read More
</Link>
</div>
)
}

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

const RelatedArticle = () => {
const data = useStaticQuery(graphql`
{
allMdx(limit: 3, sort: { frontmatter: { date: DESC } }) {
edges {
node {
frontmatter {
title
tags
date(formatString: "MMMM DD, YYYY")
}
fields {
postPath
}
}
}
}
}
`)
return (
<div className="max-w-[1264px] px-6 mx-auto py-8 md:py-16">
<div className="max-w-[670px] mx-auto flex flex-col items-center justify-center">
<div className="text-5xl leading-[116%] text-white text-center font-semibold">
Related Articles
</div>
<div className="text-lightgrey mt-6 tab-button-text text-center">
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>
<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">
{data.allMdx.edges.map((card, index) => (
<RelatedArticleCard
key={index}
title={card.node.frontmatter.title}
date={card.node.frontmatter.date}
postPath={card.node.fields.postPath}
tags={card.node.frontmatter.tags}
/>
))}
</div>
</div>
)
}

export default RelatedArticle
Loading

0 comments on commit 0b8a546

Please sign in to comment.