Skip to content

Commit b1bf5e8

Browse files
author
joanna.pineda
committed
update upcoming programs section to only show programs with date in future
1 parent 7bf6e5c commit b1bf5e8

1 file changed

Lines changed: 29 additions & 26 deletions

File tree

src/pages/programs.tsx

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -230,33 +230,36 @@ const ProgramsPage: React.FunctionComponent<PageProps> = ({ data }) => {
230230
export const UpcomingProgramsSection: React.FunctionComponent<{
231231
programs: Array<Program>
232232
withMore?: boolean
233-
}> = ({ programs, withMore = false }) => (
234-
<section className="px-8 py-20 bg-radial-gradient-c from-icterine to-white">
235-
<div className="text-center">
236-
<h2 className="mb-4 font-mono text-3xl font-bold">Upcoming Programs</h2>
237-
<p className="mb-12 text-lg font-light font-body">
238-
For beginners with little to no coding experience. Oh, and they’re all
239-
free.
240-
</p>
241-
<div className="grid items-stretch justify-center gap-4 lg:flex lg:flex-wrap">
242-
{programs
243-
.filter(({ frontmatter: { date } }) => {
244-
return date && parse(date, "yyyy-MM-dd", new Date())
245-
})
246-
.map(program => (
247-
<ProgramCard key={program.frontmatter.title} {...program} />
248-
))}
249-
</div>
250-
{withMore ? (
251-
<div className="mt-10 text-lg font-bold uppercase font-body text-iris">
252-
<Link to="/programs" className="hover:underline hover:text-black">
253-
More {">"}
254-
</Link>
233+
}> = ({ programs, withMore = false }) =>
234+
programs.filter(({ frontmatter: { date } }) => {
235+
return date && parse(date, "yyyy-MM-dd", new Date()) >= new Date()
236+
}).length > 0 ? (
237+
<section className="px-8 py-20 bg-radial-gradient-c from-icterine to-white">
238+
<div className="text-center">
239+
<h2 className="mb-4 font-mono text-3xl font-bold">Upcoming Programs</h2>
240+
<p className="mb-12 text-lg font-light font-body">
241+
For beginners with little to no coding experience. Oh, and they’re all
242+
free.
243+
</p>
244+
<div className="grid items-stretch justify-center gap-4 lg:flex lg:flex-wrap">
245+
{programs
246+
.filter(({ frontmatter: { date } }) => {
247+
return date && parse(date, "yyyy-MM-dd", new Date()) >= new Date()
248+
})
249+
.map(program => (
250+
<ProgramCard key={program.frontmatter.title} {...program} />
251+
))}
255252
</div>
256-
) : null}
257-
</div>
258-
</section>
259-
)
253+
{withMore ? (
254+
<div className="mt-10 text-lg font-bold uppercase font-body text-iris">
255+
<Link to="/programs" className="hover:underline hover:text-black">
256+
More {">"}
257+
</Link>
258+
</div>
259+
) : null}
260+
</div>
261+
</section>
262+
) : null
260263

261264
export interface Program {
262265
frontmatter: {

0 commit comments

Comments
 (0)