diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-05-24 19:35:12 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-24 19:35:12 +0200 |
| commit | c85ab5ad43ccf52881ee224672c41ec30021cf48 (patch) | |
| tree | 8058808d9bfca19383f120c46b34d99ff2f89f63 /src/ts/types/raw-data.ts | |
| parent | 52404177c07a2aab7fc894362fb3060dff2431a0 (diff) | |
| parent | 11b9de44a4b2f305a6a484187805e429b2767118 (diff) | |
refactor: use storybook and atomic design (#16)
BREAKING CHANGE: rewrite most of the Typescript types, so the content format (the meta in particular) needs to be updated.
Diffstat (limited to 'src/ts/types/raw-data.ts')
| -rw-r--r-- | src/ts/types/raw-data.ts | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/src/ts/types/raw-data.ts b/src/ts/types/raw-data.ts new file mode 100644 index 0000000..dc3db90 --- /dev/null +++ b/src/ts/types/raw-data.ts @@ -0,0 +1,105 @@ +/** + * Types for raw data coming from GraphQL API. + */ + +import { NodeResponse, PageInfo } from '@services/graphql/api'; +import { ContentKind } from './app'; + +export type ACFPosts = { + postsInThematic?: RawThematicPreview[]; + postsInTopic?: RawTopicPreview[]; +}; + +export type ACFThematics = { + postsInThematic: RawArticle[]; +}; + +export type ACFTopics = { + officialWebsite: string; + postsInTopic: RawArticle[]; +}; + +export type ContentParts = { + afterMore: string; + beforeMore: string; +}; + +export type Info = { + wordsCount: number; +}; + +export type RawAuthor<T extends ContentKind> = { + description?: T extends 'comment' ? never : string; + gravatarUrl?: string; + name: string; + url?: string; +}; + +export type RawComment = { + approved: boolean; + author: NodeResponse<RawAuthor<'comment'>>; + content: string; + databaseId: number; + date: string; + parentDatabaseId: number; +}; + +export type RawCover = { + altText: string; + mediaDetails: { + width: number; + height: number; + }; + sourceUrl: string; + title?: string; +}; + +export type RawArticle = RawPage & { + acfPosts: ACFPosts; + commentCount: number | null; +}; + +export type RawArticlePreview = Pick< + RawArticle, + 'databaseId' | 'date' | 'featuredImage' | 'slug' | 'title' +>; + +export type RawPage = { + author?: NodeResponse<RawAuthor<'page'>>; + contentParts: ContentParts; + databaseId: number; + date: string; + featuredImage: NodeResponse<RawCover> | null; + info: Info; + modified: string; + seo?: RawSEO; + slug: string; + title: string; +}; + +export type RawSEO = { + metaDesc: string; + title: string; +}; + +export type RawThematic = RawPage & { + acfThematics: ACFThematics; +}; + +export type RawThematicPreview = Pick< + RawThematic, + 'databaseId' | 'featuredImage' | 'slug' | 'title' +>; + +export type RawTopic = RawPage & { + acfTopics: ACFTopics; +}; + +export type RawTopicPreview = Pick< + RawTopic, + 'databaseId' | 'featuredImage' | 'slug' | 'title' +>; + +export type TotalItems = { + pageInfo: Pick<PageInfo, 'total'>; +}; |
