From 2718084f7e2a596f10fdd06925a60619a661f2d4 Mon Sep 17 00:00:00 2001 From: Ben Liu Date: Thu, 19 Oct 2023 11:14:13 +0700 Subject: [PATCH] feat(homepage): add id in each cards --- homepage/src/components/cards.jsx | 4 ++-- homepage/src/pages/cards.jsx | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/homepage/src/components/cards.jsx b/homepage/src/components/cards.jsx index dad06bd9..12122913 100644 --- a/homepage/src/components/cards.jsx +++ b/homepage/src/components/cards.jsx @@ -9,7 +9,7 @@ const Cards = ({ id, title, cards }) => {
{cards.map((card) => ( - + ))}
@@ -18,7 +18,7 @@ const Cards = ({ id, title, cards }) => { }; const Card = ({ card }) => ( -
+

{card.data.title}

diff --git a/homepage/src/pages/cards.jsx b/homepage/src/pages/cards.jsx index 50d12014..73b97c70 100644 --- a/homepage/src/pages/cards.jsx +++ b/homepage/src/pages/cards.jsx @@ -4,6 +4,7 @@ import { fetchPage } from '../lib/fetchPage'; import { fetchCards } from '../lib/fetchCards'; import { getNavigationList } from '../lib/getNavigationList'; import { componentMapper } from '../lib/componentMapper'; +import { titleToAnchorId } from '../lib/titleToAnchorId'; /** * @@ -20,6 +21,7 @@ export const getStaticProps = async ({ locale }) => { image = !image.startsWith('/') ? `/${image}` : image; data.image = image; + data.id = data.id || titleToAnchorId(data.title); return { data,