From f18a049bfbd1d124d3c7171d88bc900879ddc71f Mon Sep 17 00:00:00 2001 From: Tanay Pant <7481165+tanay1337@users.noreply.github.com> Date: Fri, 23 Feb 2024 20:03:07 +0100 Subject: [PATCH] feat: add dates to resources in RH (#375) * feat: add dates to resources in RH * fix: update date format to ISO 8601 * feat: display date in RH * Sort resource hub by date * fix: Minor fixes * fix: update the font for date --------- Co-authored-by: Tanay Pant Co-authored-by: louis-md --- components/ResourceHub/Card.tsx | 51 +++++++++++++++---- components/ResourceHub/Resources.tsx | 5 +- .../ResourceHub/community-resources.json | 29 +++++++++-- components/ResourceHub/company-resources.json | 42 +++++++++++++-- components/ResourceHub/useResourceSearch.ts | 15 ++++-- 5 files changed, 115 insertions(+), 27 deletions(-) diff --git a/components/ResourceHub/Card.tsx b/components/ResourceHub/Card.tsx index 6bb25c34d..26d93bd2b 100644 --- a/components/ResourceHub/Card.tsx +++ b/components/ResourceHub/Card.tsx @@ -1,12 +1,25 @@ import { Typography, Chip, Box } from '@mui/material' import css from './styles.module.css' -// import { ECOSYSTEM_DATA_URL } from '@/config/constants' import { type KnowledgeResource } from './Resources' import YouTubeEmbed from '../YouTube' -// import clsx from 'clsx' export const ProjectCard = (resource: KnowledgeResource): JSX.Element => { + const months = [ + 'January', + 'February', + 'March', + 'April', + 'May', + 'June', + 'July', + 'August', + 'September', + 'October', + 'November', + 'December' + ] + const CardContent = (
{resource.type === 'Video' && ( @@ -21,14 +34,27 @@ export const ProjectCard = (resource: KnowledgeResource): JSX.Element => { {resource.name} + + {months[new Date(resource.date).getMonth()] + + ', ' + + new Date(resource.date).getFullYear()} + + {resource.type === 'Blog Post' && ( - - {resource.abstract} - + <> + + {resource.abstract} + + )}
@@ -72,7 +98,12 @@ export const ProjectCard = (resource: KnowledgeResource): JSX.Element => { }} className={css.card} > - + {CardContent} diff --git a/components/ResourceHub/Resources.tsx b/components/ResourceHub/Resources.tsx index 124231171..410291617 100644 --- a/components/ResourceHub/Resources.tsx +++ b/components/ResourceHub/Resources.tsx @@ -46,6 +46,7 @@ export interface KnowledgeResource { url: string name: string type: string + date: string origin: string abstract?: string tags: string[] @@ -221,9 +222,7 @@ export const Resources = (): ReactElement => { <>