From 329e7c89bac50be9db2c6d2ec6751ab0ffad42ac Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Wed, 22 Nov 2023 18:12:32 +0100 Subject: refactor(components): replace items prop in Grid with children prop It is easier to read and to maintain this way. The `items` prop was not useful since we are not manipulating the items. Changes: * extract GridItem component from Grid component * replace `items` prop of type Array with `children` prop of type ReactNode * remove GridItem styles --- src/pages/index.tsx | 42 +++++----------- src/pages/projets/index.tsx | 113 ++++++++++++++++++++------------------------ 2 files changed, 64 insertions(+), 91 deletions(-) (limited to 'src/pages') diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 32c2e7f..b8f754b 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -15,7 +15,6 @@ import { CardTitle, getLayout, Grid, - type GridItem, Icon, List, ListItem, @@ -151,12 +150,11 @@ const LibreLinks: FC = () => { */ const ShaarliLink: FC = () => { const intl = useIntl(); - const shaarliUrl = PERSONAL_LINKS.SHAARLI; return ( - + {intl.formatMessage({ defaultMessage: 'Shaarli', description: 'HomePage: link to Shaarli', @@ -202,15 +200,10 @@ const MoreLinks: FC = () => { ); }; -const StyledGrid = ({ children }: { children: ReactNode[] }) => ( - { - return { id: `${index}`, item: child }; - })} - sizeMin="250px" - /> +const StyledGrid = ({ children }: { children: ReactNode }) => ( + + {children} + ); /** @@ -256,9 +249,11 @@ const HomePage: NextPageWithLayout = ({ recentPosts }) => { * @returns {JSX.Element} - The cards list. */ const getRecentPosts = (): JSX.Element => { - const posts: GridItem[] = recentPosts.map((post) => { - return { - item: ( + const listClass = `${styles.list} ${styles['list--cards']}`; + + return ( + + {recentPosts.map((post) => ( = ({ recentPosts }) => { ) : undefined } + key={post.id} meta={ = ({ recentPosts }) => { - ), - id: `${post.id}`, - }; - }); - const listClass = `${styles.list} ${styles['list--cards']}`; - - return ( - + ))} + ); }; diff --git a/src/pages/projets/index.tsx b/src/pages/projets/index.tsx index fc6eb5f..00c5a70 100644 --- a/src/pages/projets/index.tsx +++ b/src/pages/projets/index.tsx @@ -1,4 +1,3 @@ -/* eslint-disable max-statements */ import type { GetStaticProps } from 'next'; import Head from 'next/head'; import NextImage from 'next/image'; @@ -14,7 +13,6 @@ import { CardTitle, getLayout, Grid, - type GridItem, MetaList, MetaItem, Page, @@ -59,59 +57,6 @@ const ProjectsPage: NextPageWithLayout = ({ projects }) => { description: 'Meta: technologies label', id: 'ADQmDF', }); - - const items: GridItem[] = projects.map( - ({ id, meta: projectMeta, slug, title: projectTitle }) => { - const { cover, tagline, technologies } = projectMeta; - const figureLabel = intl.formatMessage( - { - defaultMessage: '{title} cover', - description: 'ProjectsPage: figure (cover) accessible name', - id: 'FdF33B', - }, - { title: projectTitle } - ); - - return { - item: ( - - - - ) : undefined - } - meta={ - technologies ? ( - - { - return { id: techno, value: techno }; - })} - /> - - ) : undefined - } - isCentered - linkTo={`${ROUTES.PROJECTS}/${slug}`} - > - - {projectTitle} - - {tagline} - - - ), - id: `${id}`, - }; - } - ); - const { asPath } = useRouter(); const webpageSchema = getWebPageSchema({ description: seo.description, @@ -165,13 +110,57 @@ const ProjectsPage: NextPageWithLayout = ({ projects }) => { intro={} /> - + + {projects.map( + ({ id, meta: projectMeta, slug, title: projectTitle }) => { + const { cover, tagline, technologies } = projectMeta; + const figureLabel = intl.formatMessage( + { + defaultMessage: '{title} cover', + description: 'ProjectsPage: figure (cover) accessible name', + id: 'FdF33B', + }, + { title: projectTitle } + ); + + return ( + + + + ) : undefined + } + key={id} + meta={ + technologies ? ( + + { + return { id: techno, value: techno }; + })} + /> + + ) : undefined + } + isCentered + linkTo={`${ROUTES.PROJECTS}/${slug}`} + > + + {projectTitle} + + {tagline} + + + ); + } + )} + ); -- cgit v1.2.3