aboutsummaryrefslogtreecommitdiffstats
path: root/src/pages/blog
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2022-05-13 19:29:41 +0200
committerArmand Philippot <git@armandphilippot.com>2022-05-13 22:35:55 +0200
commit5f3799ee75b3ac5cffe726023d8e5df129b919dd (patch)
tree573fddbe37e2257d67d81693ed0be5c46f049f2a /src/pages/blog
parent06ea295857e508a830669cb402d2156204309b1e (diff)
chore: add Thematic page
Diffstat (limited to 'src/pages/blog')
-rw-r--r--src/pages/blog/index.tsx28
1 files changed, 12 insertions, 16 deletions
diff --git a/src/pages/blog/index.tsx b/src/pages/blog/index.tsx
index 05e73db..3acf6a9 100644
--- a/src/pages/blog/index.tsx
+++ b/src/pages/blog/index.tsx
@@ -24,6 +24,10 @@ import {
} from '@ts/types/raw-data';
import { settings } from '@utils/config';
import { loadTranslation, type Messages } from '@utils/helpers/i18n';
+import {
+ getLinksListItems,
+ getPageLinkFromRawData,
+} from '@utils/helpers/pages';
import usePagination from '@utils/hooks/use-pagination';
import useSettings from '@utils/hooks/use-settings';
import { GetStaticProps, NextPage } from 'next';
@@ -203,20 +207,6 @@ const BlogPage: NextPage<BlogPageProps> = ({
setSize((prevSize) => prevSize + 1);
};
- const getLinksListItems = (
- rawData: RawThematicPreview[] | RawTopicPreview[],
- kind: 'thematic' | 'topic'
- ): LinksListItems[] => {
- const baseUrl = kind === 'thematic' ? '/thematique/' : '/sujet/';
-
- return rawData.map((taxonomy) => {
- return {
- name: taxonomy.title,
- url: `${baseUrl}${taxonomy.slug}`,
- };
- });
- };
-
const thematicsListTitle = intl.formatMessage({
defaultMessage: 'Thematics',
description: 'BlogPage: thematics list widget title',
@@ -251,13 +241,19 @@ const BlogPage: NextPage<BlogPageProps> = ({
widgets={[
<LinksListWidget
key="thematics-list"
- items={getLinksListItems(thematicsList, 'thematic')}
+ items={getLinksListItems(
+ thematicsList.map(getPageLinkFromRawData),
+ 'thematic'
+ )}
title={thematicsListTitle}
level={2}
/>,
<LinksListWidget
key="topics-list"
- items={getLinksListItems(topicsList, 'topic')}
+ items={getLinksListItems(
+ topicsList.map(getPageLinkFromRawData),
+ 'topic'
+ )}
title={topicsListTitle}
level={2}
/>,