diff options
| author | Armand Philippot <git@armandphilippot.com> | 2021-12-15 12:16:34 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2021-12-15 17:06:55 +0100 |
| commit | 0fa8ae55c52852c34c9143a6ec43c954c6404df1 (patch) | |
| tree | 32c5421025591386632c50200ce6bed3ce6e62b7 /src/ts | |
| parent | 15d247cb0d52d9c091fa040fe1d9d45e9e506050 (diff) | |
chore: retrieve posts list on blog page
Diffstat (limited to 'src/ts')
| -rw-r--r-- | src/ts/types/articles.ts | 38 | ||||
| -rw-r--r-- | src/ts/types/blog.ts | 33 | ||||
| -rw-r--r-- | src/ts/types/cover.ts | 9 | ||||
| -rw-r--r-- | src/ts/types/pagination.ts | 4 | ||||
| -rw-r--r-- | src/ts/types/taxonomies.ts | 14 |
5 files changed, 98 insertions, 0 deletions
diff --git a/src/ts/types/articles.ts b/src/ts/types/articles.ts new file mode 100644 index 0000000..5d5fbc5 --- /dev/null +++ b/src/ts/types/articles.ts @@ -0,0 +1,38 @@ +import { Cover, CoverResponse } from './cover'; +import { SubjectPreview, ThematicPreview } from './taxonomies'; + +export type ArticleDates = { + publication: string; + update: string; +}; + +export type ArticlePreviewResponse = { + acfPosts: { + postsInSubject: SubjectPreview[] | null; + postsInThematics: ThematicPreview[] | null; + }; + commentCount: number; + contentParts: { + beforeMore: string; + }; + databaseId: number; + date: string; + featuredImage: CoverResponse | null; + id: string; + modified: string; + slug: string; + title: string; +}; + +export type ArticlePreview = { + commentCount: number; + content: string; + databaseId: number; + date: ArticleDates; + featuredImage?: Cover | object; + id: string; + slug: string; + subjects: SubjectPreview[] | []; + thematics: ThematicPreview[] | []; + title: string; +}; diff --git a/src/ts/types/blog.ts b/src/ts/types/blog.ts new file mode 100644 index 0000000..345deed --- /dev/null +++ b/src/ts/types/blog.ts @@ -0,0 +1,33 @@ +import { ArticlePreview, ArticlePreviewResponse } from './articles'; +import { PageInfo } from './pagination'; + +export type PostsListEdge = { + cursor: string; + node: ArticlePreviewResponse; +}; + +export type PostsListResponse = { + posts: { + edges: PostsListEdge[]; + pageInfo: PageInfo; + }; +}; + +export type PostsList = { + posts: ArticlePreview[]; + pageInfo: PageInfo; +}; + +export type fetchPostsListReturn = ( + first?: number, + after?: string +) => Promise<PostsListResponse>; + +export type getPostsListReturn = ( + first?: number, + after?: string +) => Promise<PostsList>; + +export type BlogPageProps = { + data: PostsList; +}; diff --git a/src/ts/types/cover.ts b/src/ts/types/cover.ts new file mode 100644 index 0000000..165a26f --- /dev/null +++ b/src/ts/types/cover.ts @@ -0,0 +1,9 @@ +export type Cover = { + altText: string; + sourceUrl: string; + title: string; +}; + +export type CoverResponse = { + node: Cover; +}; diff --git a/src/ts/types/pagination.ts b/src/ts/types/pagination.ts new file mode 100644 index 0000000..45830d9 --- /dev/null +++ b/src/ts/types/pagination.ts @@ -0,0 +1,4 @@ +export type PageInfo = { + endCursor: string; + hasNextPage: boolean; +}; diff --git a/src/ts/types/taxonomies.ts b/src/ts/types/taxonomies.ts new file mode 100644 index 0000000..dd45852 --- /dev/null +++ b/src/ts/types/taxonomies.ts @@ -0,0 +1,14 @@ +import { Cover } from './cover'; + +type TaxonomyPreview = { + databaseId: number; + id: string; + slug: string; + title: string; +}; + +export type SubjectPreview = TaxonomyPreview & { + cover: Cover; +}; + +export type ThematicPreview = TaxonomyPreview; |
