aboutsummaryrefslogtreecommitdiffstats
path: root/src/ts/types/blog.ts
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2021-12-20 00:15:20 +0100
committerArmand Philippot <git@armandphilippot.com>2021-12-20 00:15:20 +0100
commitfa6adedc42e9c6ec39cc30df16b54900c220b094 (patch)
tree6bb498beadaa382245cecb86ce56931580313c6f /src/ts/types/blog.ts
parent2ff898626c5c0abc6b8195224067b992403e313b (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/blog.ts')
-rw-r--r--src/ts/types/blog.ts48
1 files changed, 15 insertions, 33 deletions
diff --git a/src/ts/types/blog.ts b/src/ts/types/blog.ts
index 32fa9b8..7325ddf 100644
--- a/src/ts/types/blog.ts
+++ b/src/ts/types/blog.ts
@@ -1,47 +1,29 @@
-import {
- ArticlePreview,
- ArticlePreviewResponse,
- ArticleSlug,
-} from './articles';
-import { PageInfo } from './pagination';
-
-export type PostsListEdge = {
- cursor: string;
- node: ArticlePreviewResponse;
-};
-
-export type PostsListResponse = {
- posts: {
- edges: PostsListEdge[];
- pageInfo: PageInfo;
- };
-};
+import { PageInfo, Slug } from './app';
+import { ArticlePreview, RawArticlePreview } from './articles';
export type PostsList = {
posts: ArticlePreview[];
pageInfo: PageInfo;
};
-export type FetchPostsListReturn = (
- first?: number,
- after?: string
-) => Promise<PostsListResponse>;
-
-type PostsListProps = {
- first?: number;
- after?: string;
+export type PostsListEdges = {
+ cursor: string;
+ node: RawArticlePreview;
};
-export type GetPostsListReturn = (props: PostsListProps) => Promise<PostsList>;
-
-export type BlogPageProps = {
- fallback: PostsList;
+export type RawPostsList = {
+ posts: {
+ edges: PostsListEdges[];
+ pageInfo: PageInfo;
+ };
};
-export type AllPostsSlugResponse = {
+export type AllPostsSlug = {
posts: {
- nodes: ArticleSlug[];
+ nodes: Slug[];
};
};
-export type FetchAllPostsSlugReturn = () => Promise<ArticleSlug[]>;
+export type BlogPageProps = {
+ fallback: PostsList;
+};