diff options
| author | Armand Philippot <git@armandphilippot.com> | 2021-12-20 00:15:20 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2021-12-20 00:15:20 +0100 |
| commit | fa6adedc42e9c6ec39cc30df16b54900c220b094 (patch) | |
| tree | 6bb498beadaa382245cecb86ce56931580313c6f /src/ts/types/app.ts | |
| parent | 2ff898626c5c0abc6b8195224067b992403e313b (diff) | |
refactor: rewrite types and services
I was repeating myself a lot in services. So I rewrited the different
functions to improve readability and I extracted some formatting
functions to put them in utils. I also rewrited/reorganized some types
to keep consistent names.
Diffstat (limited to 'src/ts/types/app.ts')
| -rw-r--r-- | src/ts/types/app.ts | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/src/ts/types/app.ts b/src/ts/types/app.ts index 488fe6e..ba28416 100644 --- a/src/ts/types/app.ts +++ b/src/ts/types/app.ts @@ -1,6 +1,22 @@ import { NextPage } from 'next'; import { AppProps } from 'next/app'; import { ReactElement, ReactNode } from 'react'; +import { PostBy } from './articles'; +import { AllPostsSlug, RawPostsList } from './blog'; +import { CommentData, CreateComment } from './comments'; +import { ContactData, SendEmail } from './contact'; +import { HomePageBy } from './homepage'; +import { PageBy } from './pages'; +import { + AllSubjectsSlug, + AllThematicsSlug, + SubjectBy, + ThematicBy, +} from './taxonomies'; + +//============================================================================== +// Next +//============================================================================== export type NextPageWithLayout<P = {}> = NextPage<P> & { getLayout?: (page: ReactElement) => ReactNode; @@ -9,3 +25,62 @@ export type NextPageWithLayout<P = {}> = NextPage<P> & { export type AppPropsWithLayout = AppProps & { Component: NextPageWithLayout; }; + +//============================================================================== +// API +//============================================================================== + +export type VariablesType<T> = T extends + | PageBy + | PostBy + | SubjectBy + | ThematicBy + ? Slug + : T extends RawPostsList + ? CursorPagination + : T extends CreateComment + ? CommentData + : T extends SendEmail + ? ContactData + : null; + +export type RequestType = + | AllPostsSlug + | AllSubjectsSlug + | AllThematicsSlug + | CreateComment + | HomePageBy + | PageBy + | PostBy + | SubjectBy + | ThematicBy + | RawPostsList + | SendEmail; + +//============================================================================== +// Globals +//============================================================================== + +export type ContentParts = { + afterMore: string; + beforeMore: string; +}; + +export type CursorPagination = { + first: number; + after: string; +}; + +export type Dates = { + publication: string; + update: string; +}; + +export type PageInfo = { + endCursor: string; + hasNextPage: boolean; +}; + +export type Slug = { + slug: string; +}; |
