Skip to content

Commit

Permalink
feat: Filter News tag
Browse files Browse the repository at this point in the history
  • Loading branch information
ChefMomota committed Jul 24, 2023
1 parent ad4e99d commit dc3c3c1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions apps/blog/hooks/getArticle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ export const getSingleArticle = async ({ url, urlParamsObject = {} }: GetArticle
publishedAt: '',
description: '',
categories: [],
newsOutBoundLink: '',
newsFromPlatform: '',
}
}
}
Expand All @@ -53,6 +55,11 @@ export const getCategories = async (): Promise<Categories[]> => {
try {
const response = await fetchAPI('/categories', {
fields: 'id,name',
filters: {
name: {
$not: 'News',
},
},
})

return (response.data as ResponseCategoriesType[]).map((category) => ({
Expand Down
2 changes: 2 additions & 0 deletions apps/blog/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ export interface ResponseArticleDataType {
image: {
data: ArticleImageType[]
}
newsOutBoundLink: string
newsFromPlatform: string
}
}

Expand Down
4 changes: 4 additions & 0 deletions apps/blog/utils/transformArticle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export interface ArticleDataType {
publishedAt: string
description: string
categories: Array<string>
newsOutBoundLink: string
newsFromPlatform: string
}

export interface ArticleType {
Expand All @@ -28,6 +30,8 @@ export const transformArticle = (article: ResponseArticleDataType): ArticleDataT
publishedAt: article?.attributes?.publishedAt ?? '',
locale: article?.attributes?.locale ?? '',
description: article?.attributes?.description ?? '',
newsFromPlatform: article?.attributes?.newsFromPlatform ?? '',
newsOutBoundLink: article?.attributes?.newsOutBoundLink ?? '',
imgUrl: article?.attributes?.image?.data?.[0]?.attributes?.url ?? '',
categories: article.attributes?.categories?.data?.map((i) => i.attributes.name),
}
Expand Down

0 comments on commit dc3c3c1

Please sign in to comment.