summaryrefslogtreecommitdiffstats
path: root/src/pages/blog/page
diff options
context:
space:
mode:
Diffstat (limited to 'src/pages/blog/page')
-rw-r--r--src/pages/blog/page/[number].tsx66
1 files changed, 3 insertions, 63 deletions
diff --git a/src/pages/blog/page/[number].tsx b/src/pages/blog/page/[number].tsx
index e8c93f7..8f50ddd 100644
--- a/src/pages/blog/page/[number].tsx
+++ b/src/pages/blog/page/[number].tsx
@@ -1,10 +1,9 @@
-import PostsList, { type Post } from '@components/organisms/layout/posts-list';
+import PostsList from '@components/organisms/layout/posts-list';
import LinksListWidget from '@components/organisms/widgets/links-list-widget';
import { getLayout } from '@components/templates/layout/layout';
import PageLayout from '@components/templates/page/page-layout';
import { type EdgesResponse } from '@services/graphql/api';
import {
- getArticleFromRawData,
getArticles,
getArticlesEndCursor,
getTotalArticles,
@@ -14,11 +13,7 @@ import {
getTotalThematics,
} from '@services/graphql/thematics';
import { getTopicsPreview, getTotalTopics } from '@services/graphql/topics';
-import {
- type Article,
- type Meta,
- type NextPageWithLayout,
-} from '@ts/types/app';
+import { type NextPageWithLayout } from '@ts/types/app';
import {
type RawArticle,
type RawThematicPreview,
@@ -29,6 +24,7 @@ import { loadTranslation, type Messages } from '@utils/helpers/i18n';
import {
getLinksListItems,
getPageLinkFromRawData,
+ getPostsList,
} from '@utils/helpers/pages';
import useBreadcrumb from '@utils/hooks/use-breadcrumb';
import useRedirection from '@utils/hooks/use-redirection';
@@ -131,62 +127,6 @@ const BlogPage: NextPageWithLayout<BlogPageProps> = ({
'@graph': [webpageSchema, blogSchema],
};
- /**
- * Retrieve the formatted meta.
- *
- * @param {Meta<'article'>} meta - The article meta.
- * @returns {Post['meta']} The formatted meta.
- */
- const getPostMeta = (meta: Meta<'article'>): Post['meta'] => {
- const { commentsCount, dates, thematics, wordsCount } = meta;
-
- return {
- commentsCount,
- dates,
- readingTime: { wordsCount: wordsCount || 0, onlyMinutes: true },
- thematics: thematics?.map((thematic) => {
- return { ...thematic, url: `/thematique/${thematic.slug}` };
- }),
- };
- };
-
- /**
- * Retrieve the formatted posts.
- *
- * @param {Article[]} posts - An array of articles.
- * @returns {Post[]} An array of formatted posts.
- */
- const getPosts = (posts: Article[]): Post[] => {
- return posts.map((post) => {
- return {
- ...post,
- cover: post.meta.cover,
- excerpt: post.intro,
- meta: getPostMeta(post.meta),
- url: `/article/${post.slug}`,
- };
- });
- };
-
- /**
- * Retrieve the posts list from raw data.
- *
- * @param {EdgesResponse<RawArticle>[]} rawData - The raw data.
- * @returns {Post[]} An array of posts.
- */
- const getPostsList = (rawData: EdgesResponse<RawArticle>[]): Post[] => {
- const articlesList: RawArticle[] = [];
- rawData.forEach((articleData) =>
- articleData.edges.forEach((edge) => {
- articlesList.push(edge.node);
- })
- );
-
- return getPosts(
- articlesList.map((article) => getArticleFromRawData(article))
- );
- };
-
const thematicsListTitle = intl.formatMessage({
defaultMessage: 'Thematics',
description: 'BlogPage: thematics list widget title',