diff options
Diffstat (limited to 'src/services/graphql/helpers/convert-wp-thematic-to-thematic.ts')
| -rw-r--r-- | src/services/graphql/helpers/convert-wp-thematic-to-thematic.ts | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/src/services/graphql/helpers/convert-wp-thematic-to-thematic.ts b/src/services/graphql/helpers/convert-wp-thematic-to-thematic.ts index 9aa1896..5f8d7fc 100644 --- a/src/services/graphql/helpers/convert-wp-thematic-to-thematic.ts +++ b/src/services/graphql/helpers/convert-wp-thematic-to-thematic.ts @@ -8,6 +8,7 @@ import { ROUTES } from '../../../utils/constants'; import { getUniquePageLinks, sortPageLinksByName, + updateContentTree, } from '../../../utils/helpers'; import { convertPostPreviewToArticlePreview } from './convert-post-preview-to-article-preview'; import { convertWPTopicPreviewToPageLink } from './convert-taxonomy-to-page-link'; @@ -31,30 +32,39 @@ const getRelatedTopicsFrom = (posts: WPPostPreview[]): PageLink[] => { return getUniquePageLinks(topics).sort(sortPageLinksByName); }; -export const convertWPThematicToThematic = (thematic: WPThematic): Thematic => { +export const convertWPThematicToThematic = ({ + acfThematics, + contentParts, + databaseId, + date, + featuredImage, + modified, + seo, + slug, + title, +}: WPThematic): Thematic => { return { - content: thematic.contentParts.afterMore, - intro: thematic.contentParts.beforeMore, + content: updateContentTree(contentParts.afterMore), + id: databaseId, + intro: contentParts.beforeMore, meta: { - articles: thematic.acfThematics?.postsInThematic?.map( + articles: acfThematics?.postsInThematic?.map( convertPostPreviewToArticlePreview ), - cover: thematic.featuredImage - ? convertWPImgToImg(thematic.featuredImage.node) - : undefined, + cover: featuredImage ? convertWPImgToImg(featuredImage.node) : undefined, dates: { - publication: thematic.date, - update: thematic.modified, + publication: date, + update: modified, }, seo: { - description: thematic.seo.metaDesc, - title: thematic.seo.title, + description: seo.metaDesc, + title: seo.title, }, - relatedTopics: thematic.acfThematics?.postsInThematic - ? getRelatedTopicsFrom(thematic.acfThematics.postsInThematic) + relatedTopics: acfThematics?.postsInThematic + ? getRelatedTopicsFrom(acfThematics.postsInThematic) : undefined, }, - slug: `${ROUTES.THEMATICS}/${thematic.slug}`, - title: thematic.title, + slug: `${ROUTES.THEMATICS}/${slug}`, + title, }; }; |
