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/utils/helpers/pages.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/utils/helpers/pages.tsx') diff --git a/src/utils/helpers/pages.tsx b/src/utils/helpers/pages.tsx index 556b4fb..62a582f 100644 --- a/src/utils/helpers/pages.tsx +++ b/src/utils/helpers/pages.tsx @@ -1,5 +1,5 @@ import NextImage from 'next/image'; -import type { LinksListItems, PostData } from '../../components'; +import type { LinksWidgetItemData, PostData } from '../../components'; import { getArticleFromRawData } from '../../services/graphql'; import type { Article, @@ -61,10 +61,11 @@ export const sortPageLinksByName = (a: PageLink, b: PageLink) => { * @param {PageLink[]} links - An array of page links. * @returns {LinksListItem[]} An array of links items. */ -export const getLinksListItems = (links: PageLink[]): LinksListItems[] => +export const getLinksItemData = (links: PageLink[]): LinksWidgetItemData[] => links.map((link) => { return { - name: link.name, + id: `${link.id}`, + label: link.name, url: link.url, }; }); -- cgit v1.2.3