forked from CodingCatDev/codingcat.dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
178 lines (161 loc) · 3.13 KB
/
index.ts
File metadata and controls
178 lines (161 loc) · 3.13 KB
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
export interface Content {
id: string;
authors?: string[];
cloudinary_conver?: boolean;
html?: string;
cover?: string;
devto?: string;
end?: Date;
excerpt?: string;
hashnode?: string;
preview?: string;
published?: ContentPublished;
slug: string;
start: Date;
sponsors?: string[];
type: ContentType;
title: string;
updated?: Date;
weight?: number;
youtube?: string;
}
export interface Course extends Content {
lesson?: Lesson[];
}
export interface Lesson extends Content {
codepen?: string;
courseSlug?: string;
lesson?: Lesson[];
section?: string;
locked: boolean;
stackblitz?: string;
}
export interface Podcast extends Content {
season?: number;
episode?: number;
recording_date?: Date;
podcast?: PodcastType;
guests?: string[]; // Guest Slug
picks?: Pick[];
// Exports
devto?: string;
hashnode?: string;
spotify?: string;
}
export interface Sponsor extends Content {
description: string;
name: string;
url: string;
}
export interface Author extends Content {
name: string;
socials: Socials;
websites?: string[];
}
export interface Pick {
author?: string;
name?: string;
site?: string;
}
export enum ContentType {
author = 'author',
course = 'course',
framework = 'framework',
forum = 'forum',
guest = 'guest',
group = 'group',
language = 'language',
lesson = 'lesson',
page = 'page',
podcast = 'podcast',
post = 'post',
sponsor = 'sponsor'
}
export enum PodcastType {
codingcatdev = 'codingcatdev'
}
export interface Socials {
codepen?: string;
devto?: string;
discord?: string;
dribbble?: string;
facebook?: string;
github?: string;
instagram?: string;
linkedin?: string;
email?: string;
mastodon?: string;
medium?: string;
polywork?: string;
stackoverflow?: string;
substack?: string;
tiktok?: string;
twitch?: string;
twitter?: string;
youtube?: string;
}
export enum ContentPublished {
archived = 'archived',
draft = 'draft',
published = 'published'
}
/**
* Array of ContentTypes
* @readonly
* @return {string[]}
*/
export const getContentTypes = () => {
return Object.keys(ContentType);
};
/**
* Array of ContentTypes Plural
* @readonly
* @return {Map<string,string>}
*/
export const getContentTypePlurals = () => {
const map = new Map();
Object.keys(ContentType).map((t) => map.set(t, t === ContentType.post ? 'blog' : t + 's'));
return map;
};
/**
* Array of ContentTypes Plural
* @readonly
* @param {string} contentType
* @return {string | undefined}
*/
export const getContentTypePlural = (contentType: ContentType) => {
return getContentTypePlurals().get(contentType);
};
export interface FileStub {
type: 'file';
name: string;
basename: string;
contents: string;
text: boolean;
}
export interface DirectoryStub {
type: 'directory';
name: string;
basename: string;
}
export type Stub = FileStub | DirectoryStub;
export interface UserDoc {
pro?: Pro;
}
export interface Pro {
settings?: {
showDrafts?: boolean;
};
completed?: PathDate[];
bookmarked?: PathDate[];
}
export interface PathDate {
path: string;
date: number;
}
export interface Saved extends Content, Lesson {
savedId: string;
savedUpdated: Date;
savedComplete: boolean;
lesson?: Saved[];
}