1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
import type { ArticlePreview, WPPostPreview } from '../../../types';
import { convertWPThematicPreviewToPageLink } from './convert-taxonomy-to-page-link';
import { convertWPImgToImg } from './convert-wp-image-to-img';
export const convertPostPreviewToArticlePreview = ({
acfPosts,
commentCount,
contentParts,
databaseId,
date,
featuredImage,
info,
modified,
slug,
title,
}: WPPostPreview): ArticlePreview => {
return {
id: databaseId,
intro: contentParts.beforeMore,
meta: {
commentsCount: typeof commentCount === 'number' ? commentCount : 0,
cover: featuredImage ? convertWPImgToImg(featuredImage.node) : undefined,
dates: {
publication: date,
update: modified,
},
thematics:
acfPosts && 'postsInThematic' in acfPosts
? acfPosts.postsInThematic?.map(convertWPThematicPreviewToPageLink)
: undefined,
wordsCount: info.wordsCount,
},
slug,
title,
};
};
|