From a3a4c50f26b8750ae1c87f1f1103b84b7d2e6315 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Tue, 14 Nov 2023 15:11:22 +0100 Subject: refactor(components): replace LinksListWidget with LinksWidget * avoid List component repeat * rewrite tests and CSS * add an id to LinksWidgetItemData (previously LinksListItems) type because the label could be duplicated --- src/pages/404.tsx | 12 ++++++------ src/pages/blog/index.tsx | 12 ++++++------ src/pages/blog/page/[number].tsx | 12 ++++++------ src/pages/recherche/index.tsx | 12 ++++++------ src/pages/sujet/[slug].tsx | 12 ++++++------ src/pages/thematique/[slug].tsx | 12 ++++++------ 6 files changed, 36 insertions(+), 36 deletions(-) (limited to 'src/pages') diff --git a/src/pages/404.tsx b/src/pages/404.tsx index 00e2d5a..2b6ddf3 100644 --- a/src/pages/404.tsx +++ b/src/pages/404.tsx @@ -8,7 +8,7 @@ import { getLayout, Heading, Link, - LinksListWidget, + LinksWidget, PageLayout, SearchForm, type SearchFormSubmit, @@ -25,7 +25,7 @@ import type { RawTopicPreview, } from '../types'; import { ROUTES } from '../utils/constants'; -import { getLinksListItems, getPageLinkFromRawData } from '../utils/helpers'; +import { getLinksItemData, getPageLinkFromRawData } from '../utils/helpers'; import { loadTranslation, type Messages } from '../utils/helpers/server'; import { useBreadcrumb, useSettings } from '../utils/hooks'; @@ -122,13 +122,13 @@ const Error404Page: NextPageWithLayout = ({ breadcrumb={breadcrumbItems} breadcrumbSchema={breadcrumbSchema} widgets={[ - {thematicsListTitle} } - items={getLinksListItems( + items={getLinksItemData( thematicsList.map((thematic) => getPageLinkFromRawData(thematic, 'thematic') ) @@ -136,13 +136,13 @@ const Error404Page: NextPageWithLayout = ({ // eslint-disable-next-line react/jsx-no-literals -- Key allowed key="thematics-list" />, - {topicsListTitle} } - items={getLinksListItems( + items={getLinksItemData( topicsList.map((topic) => getPageLinkFromRawData(topic, 'topic')) )} // eslint-disable-next-line react/jsx-no-literals -- Key allowed diff --git a/src/pages/blog/index.tsx b/src/pages/blog/index.tsx index 678b75a..e5fc2c2 100644 --- a/src/pages/blog/index.tsx +++ b/src/pages/blog/index.tsx @@ -8,7 +8,7 @@ import { useIntl } from 'react-intl'; import { getLayout, Heading, - LinksListWidget, + LinksWidget, type MetaItemData, Notice, PageLayout, @@ -37,7 +37,7 @@ import { settings } from '../../utils/config'; import { ROUTES } from '../../utils/constants'; import { getBlogSchema, - getLinksListItems, + getLinksItemData, getPageLinkFromRawData, getSchemaJson, getWebPageSchema, @@ -242,13 +242,13 @@ const BlogPage: NextPageWithLayout = ({ breadcrumbSchema={breadcrumbSchema} headerMeta={headerMeta} widgets={[ - {thematicsListTitle} } - items={getLinksListItems( + items={getLinksItemData( thematicsList.map((thematic) => getPageLinkFromRawData(thematic, 'thematic') ) @@ -256,13 +256,13 @@ const BlogPage: NextPageWithLayout = ({ // eslint-disable-next-line react/jsx-no-literals -- Key allowed key="thematics-list" />, - {topicsListTitle} } - items={getLinksListItems( + items={getLinksItemData( topicsList.map((topic) => getPageLinkFromRawData(topic, 'topic')) )} // eslint-disable-next-line react/jsx-no-literals -- Key allowed diff --git a/src/pages/blog/page/[number].tsx b/src/pages/blog/page/[number].tsx index 842c2b8..5f6a2d6 100644 --- a/src/pages/blog/page/[number].tsx +++ b/src/pages/blog/page/[number].tsx @@ -9,7 +9,7 @@ import { useIntl } from 'react-intl'; import { getLayout, Heading, - LinksListWidget, + LinksWidget, type MetaItemData, PageLayout, PostsList, @@ -36,7 +36,7 @@ import type { import { settings } from '../../../utils/config'; import { getBlogSchema, - getLinksListItems, + getLinksItemData, getPageLinkFromRawData, getPostsList, getSchemaJson, @@ -237,13 +237,13 @@ const BlogPage: NextPageWithLayout = ({ breadcrumbSchema={breadcrumbSchema} headerMeta={headerMeta} widgets={[ - {thematicsListTitle} } - items={getLinksListItems( + items={getLinksItemData( thematicsList.map((thematic) => getPageLinkFromRawData(thematic, 'thematic') ) @@ -251,13 +251,13 @@ const BlogPage: NextPageWithLayout = ({ // eslint-disable-next-line react/jsx-no-literals -- Key allowed key="thematics-list" />, - {topicsListTitle} } - items={getLinksListItems( + items={getLinksItemData( topicsList.map((topic) => getPageLinkFromRawData(topic, 'topic')) )} // eslint-disable-next-line react/jsx-no-literals -- Key allowed diff --git a/src/pages/recherche/index.tsx b/src/pages/recherche/index.tsx index effd087..87e6171 100644 --- a/src/pages/recherche/index.tsx +++ b/src/pages/recherche/index.tsx @@ -8,7 +8,7 @@ import { useIntl } from 'react-intl'; import { getLayout, Heading, - LinksListWidget, + LinksWidget, type MetaItemData, Notice, PageLayout, @@ -34,7 +34,7 @@ import type { import { ROUTES } from '../../utils/constants'; import { getBlogSchema, - getLinksListItems, + getLinksItemData, getPageLinkFromRawData, getSchemaJson, getWebPageSchema, @@ -222,13 +222,13 @@ const SearchPage: NextPageWithLayout = ({ breadcrumbSchema={breadcrumbSchema} headerMeta={headerMeta} widgets={[ - {thematicsListTitle} } - items={getLinksListItems( + items={getLinksItemData( thematicsList.map((thematic) => getPageLinkFromRawData(thematic, 'thematic') ) @@ -236,13 +236,13 @@ const SearchPage: NextPageWithLayout = ({ // eslint-disable-next-line react/jsx-no-literals -- Key allowed key="thematics-list" />, - {topicsListTitle} } - items={getLinksListItems( + items={getLinksItemData( topicsList.map((topic) => getPageLinkFromRawData(topic, 'topic')) )} // eslint-disable-next-line react/jsx-no-literals -- Key allowed diff --git a/src/pages/sujet/[slug].tsx b/src/pages/sujet/[slug].tsx index 66c3d02..d841b73 100644 --- a/src/pages/sujet/[slug].tsx +++ b/src/pages/sujet/[slug].tsx @@ -9,7 +9,7 @@ import { useIntl } from 'react-intl'; import { getLayout, Heading, - LinksListWidget, + LinksWidget, type MetaItemData, PageLayout, PostsList, @@ -25,7 +25,7 @@ import styles from '../../styles/pages/blog.module.scss'; import type { NextPageWithLayout, PageLink, Topic } from '../../types'; import { ROUTES } from '../../utils/constants'; import { - getLinksListItems, + getLinksItemData, getPageLinkFromRawData, getPostsWithUrl, getSchemaJson, @@ -185,23 +185,23 @@ const TopicPage: NextPageWithLayout = ({ widgets={ thematics ? [ - {thematicsListTitle} } - items={getLinksListItems(thematics)} + items={getLinksItemData(thematics)} // eslint-disable-next-line react/jsx-no-literals -- Key allowed key="related-thematics" />, - {topicsListTitle} } - items={getLinksListItems(topics)} + items={getLinksItemData(topics)} // eslint-disable-next-line react/jsx-no-literals -- Key allowed key="topics" />, diff --git a/src/pages/thematique/[slug].tsx b/src/pages/thematique/[slug].tsx index 61d105e..20c1ee8 100644 --- a/src/pages/thematique/[slug].tsx +++ b/src/pages/thematique/[slug].tsx @@ -8,7 +8,7 @@ import { useIntl } from 'react-intl'; import { getLayout, Heading, - LinksListWidget, + LinksWidget, type MetaItemData, PageLayout, PostsList, @@ -24,7 +24,7 @@ import styles from '../../styles/pages/blog.module.scss'; import type { NextPageWithLayout, PageLink, Thematic } from '../../types'; import { ROUTES } from '../../utils/constants'; import { - getLinksListItems, + getLinksItemData, getPageLinkFromRawData, getPostsWithUrl, getSchemaJson, @@ -158,23 +158,23 @@ const ThematicPage: NextPageWithLayout = ({ widgets={ topics ? [ - {thematicsListTitle} } - items={getLinksListItems(thematics)} + items={getLinksItemData(thematics)} // eslint-disable-next-line react/jsx-no-literals -- Key allowed key="thematics" />, - {topicsListTitle} } - items={getLinksListItems(topics)} + items={getLinksItemData(topics)} // eslint-disable-next-line react/jsx-no-literals -- Key allowed key="related-topics" />, -- cgit v1.2.3