aboutsummaryrefslogtreecommitdiffstats
path: root/src/types/data.ts
blob: f58d6e73bebabdc4c89bd5c40268ab90b03e18d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
import type { StaticImageData } from 'next/image';
import type { Nullable } from './generics';
import type { GraphQLNode } from './gql';

export type SlugNode = {
  slug: string;
};

//===========================================================================
// Data from WordPress
//===========================================================================

type WPSeo = {
  metaDesc: string;
  title: string;
};

type WPCommentAuthorAvatar = {
  height: number;
  url: string;
  width: number;
};

type WPCommentAuthor = {
  avatar: Nullable<WPCommentAuthorAvatar>;
  name: string;
  url: Nullable<string>;
};

export type WPCommentStatus = 'APPROVE' | 'HOLD' | 'SPAM' | 'TRASH';

export type WPComment = {
  approved: boolean;
  author: GraphQLNode<WPCommentAuthor>;
  content: string;
  databaseId: number;
  date: string;
  parentDatabaseId: number;
  status: WPCommentStatus;
};

type WPContentParts = {
  afterMore: string;
  beforeMore: string;
};

export type WPImage = {
  altText: Nullable<string>;
  mediaDetails: {
    height: number;
    width: number;
  };
  sourceUrl: string;
  title: Nullable<string>;
};

type WPInfo = { wordsCount: number };

type WPContent = {
  contentParts: WPContentParts;
  databaseId: number;
  date: string;
  featuredImage: Nullable<GraphQLNode<WPImage>>;
  modified: string;
  seo: WPSeo;
  slug: string;
  title: string;
};

export type WPPage = WPContent & {
  info: WPInfo;
};

type WPPostAuthor = { name: string };

type WPAcfPosts = {
  postsInThematic: Nullable<WPThematicPreview[]>;
  postsInTopic: Nullable<WPTopicPreview[]>;
};

export type WPPost = WPContent & {
  acfPosts: Nullable<Partial<WPAcfPosts>>;
  author: GraphQLNode<WPPostAuthor>;
  commentCount: Nullable<number>;
  info: WPInfo;
};

export type WPPostPreview = Pick<
  WPPost,
  | 'commentCount'
  | 'databaseId'
  | 'date'
  | 'featuredImage'
  | 'info'
  | 'modified'
  | 'slug'
  | 'title'
> & {
  acfPosts:
    | Nullable<Pick<WPAcfPosts, 'postsInThematic'>>
    | Nullable<Pick<WPAcfPosts, 'postsInTopic'>>;
  contentParts: Pick<WPContentParts, 'beforeMore'>;
};

export type RecentWPPost = Pick<
  WPPost,
  'date' | 'featuredImage' | 'slug' | 'title'
> & {
  databaseId: number;
};

type WPAcfThematics = {
  postsInThematic: Nullable<WPPostPreview[]>;
};

export type WPThematic = WPContent & {
  acfThematics: Nullable<WPAcfThematics>;
};

export type WPThematicPreview = Pick<
  WPThematic,
  'databaseId' | 'slug' | 'title'
>;

type WPAcfTopics = {
  officialWebsite: Nullable<string>;
  postsInTopic: Nullable<WPPostPreview[]>;
};

export type WPTopic = WPContent & {
  acfTopics: Nullable<WPAcfTopics>;
};

export type WPTopicPreview = Pick<
  WPTopic,
  'databaseId' | 'featuredImage' | 'slug' | 'title'
>;

//===========================================================================
// Data from MDX files
//===========================================================================

export type MDXData = {
  file: string;
  image: MDXImage;
};

export type MDXImage = StaticImageData & {
  alt: string;
  title?: string;
};

export type MDXPageMeta = Omit<PageMeta, 'wordsCount'> & {
  intro: string;
  title: string;
};

export type MDXProjectMeta = Omit<ProjectMeta, 'wordsCount'> & {
  intro: string;
  title: string;
};

//===========================================================================
// Data used in this application
//===========================================================================

export type Dates = {
  publication: string;
  update?: string;
};

export type SEO = {
  description: string;
  title: string;
};

export type Img = {
  alt: string;
  height: number;
  src: string;
  title?: string;
  width: number;
};

export type CommentAuthor = {
  avatar?: Omit<Img, 'title'>;
  name: string;
  website?: string;
};

export type CommentMeta = {
  author: CommentAuthor;
  date: string;
};

export type SingleComment = {
  content: string;
  id: number;
  isApproved: boolean;
  meta: CommentMeta;
  parentId?: number;
  replies: SingleComment[];
};

export type PageMeta = {
  cover?: Img;
  dates: Dates;
  seo: SEO;
  wordsCount: number;
};

export type Page = {
  content: string;
  intro: string;
  slug: string;
  title: string;
};

export type PageLink = {
  id: number;
  logo?: Img;
  name: string;
  url: string;
};

type ArticleMeta = PageMeta & {
  author?: string;
  commentsCount?: number;
  thematics?: PageLink[];
  topics?: PageLink[];
};

export type Article = Page & {
  id: number;
  meta: ArticleMeta;
};

export type ArticlePreview = Pick<Article, 'intro' | 'slug' | 'title'> & {
  id: number;
  meta: Omit<ArticleMeta, 'author' | 'seo' | 'topics'>;
};

export type RecentArticle = Pick<Article, 'slug' | 'title'> &
  Pick<ArticleMeta, 'cover'> & {
    id: number;
    publicationDate: string;
  };

export type Repos = {
  github?: string;
  gitlab?: string;
};

export type ProjectMeta = Omit<PageMeta, 'wordsCount'> & {
  contexts?: string[];
  license?: string;
  repos: Repos;
  tagline?: string;
  technologies?: string[];
};

export type Project = Omit<Page, 'content'> & {
  id: string;
  meta: ProjectMeta;
};

export type ProjectPreview = Omit<Project, 'meta'> & {
  meta: Pick<ProjectMeta, 'contexts' | 'cover' | 'dates' | 'tagline'>;
};

export type ThematicMeta = Omit<PageMeta, 'wordsCount'> & {
  articles?: ArticlePreview[];
  relatedTopics?: PageLink[];
};

export type Thematic = Page & {
  id: number;
  meta: ThematicMeta;
};

export type TopicMeta = Omit<PageMeta, 'wordsCount'> & {
  articles?: ArticlePreview[];
  relatedThematics?: PageLink[];
  website?: string;
};

export type Topic = Page & {
  id: number;
  meta: TopicMeta;
};

export type GithubRepositoryMeta = {
  createdAt: string;
  stargazerCount: number;
  updatedAt: string;
};