generated from thedemonsid/blog-website-speedrun
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathseed.js
187 lines (166 loc) · 4.63 KB
/
seed.js
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
const { PrismaClient } = require("@prisma/client");
const prisma = new PrismaClient();
async function main() {
// Create courses
const courses = await prisma.course.createMany({
data: [
{
name: "Introduction to Markdown",
slug: "introduction-to-markdown",
description:
"Learn how to use MDX to create dynamic content with JSX and Markdown",
},
{
name: "React Fundamentals",
slug: "react-fundamentals",
description: "Master the core concepts of React development",
},
{
name: "Next.js Advanced Patterns",
slug: "nextjs-advanced-patterns",
description: "Deep dive into Next.js framework features and patterns",
},
{
name: "TypeScript for JavaScript Developers",
slug: "typescript-for-javascript-developers",
description:
"Learn TypeScript to write more maintainable JavaScript code",
},
{
name: "Full-Stack Development with Prisma",
slug: "full-stack-development-with-prisma",
description: "Learn how to use Prisma for full-stack development",
},
],
});
// Create modules for the first course
const course = await prisma.course.findUnique({
where: { slug: "introduction-to-markdown" },
});
const modules = await prisma.module.createMany({
data: [
{
name: "Getting Started with Markdown",
slug: "getting-started-with-markdown",
description: "Introduction to Markdown syntax and usage",
courseId: course.id,
index: 1,
isFree: true,
},
{
name: "Advanced Markdown Techniques",
slug: "advanced-markdown-techniques",
description: "Learn advanced Markdown techniques",
courseId: course.id,
index: 2,
isFree: false,
},
],
});
// Create lessons for the first module
const module = await prisma.module.findUnique({
where: {
slug_courseId: {
slug: "getting-started-with-markdown",
courseId: course.id,
},
},
});
const mdxContent = `
---
title : Hello World
publishedAt: 2021-07-10
summary: "This is a Demo Blog for the testing purposes"
category: "Hello"
author: "the_demon_sid"
---
# Hello World
A checkbox is a square box that can be activated or deactivated when ticked.
Use checkboxes to select one or more options from a list of choices.
<MyComponent/>
\`\`\`javascript
import { Checkbox } from '@react-spectrum/checkbox';
function Example() {
return <Checkbox>Label</Checkbox>;
}
\`\`\`
\`\`\`jsx
<Checkbox>Label</Checkbox>
\`\`\`
\`\`\`html
<input type="checkbox" id="checkbox" name="checkbox" value="checkbox">
<label for="checkbox">Label</label>
\`\`\`
A checkbox is a square box that can be activated or deactivated when ticked.
Use checkboxes to select one or more options from a list of choices.
\`\`\`javascript
import { Checkbox } from '@react-spectrum/checkbox';
function Example() {
return <Checkbox>Label</Checkbox>;
}
\`\`\`
\`\`\`jsx
<Checkbox>Label</Checkbox>
\`\`\`
\`\`\`html
<input type="checkbox" id="checkbox" name="checkboxconst mdxContent
# Hello World
A checkbox is a square box that can be activated or deactivated when ticked.
Use checkboxes to select one or more options from a list of choices.
<MyComponent/>
\`\`\`javascript
import { Checkbox } from '@react-spectrum/checkbox';
function Example() {
return <Checkbox>Label</Checkbox>;
}
\`\`\`
\`\`\`jsx
<Checkbox>Label</Checkbox>
\`\`\`
\`\`\`html
<input type="checkbox" id="checkbox" name="checkbox" value="checkbox">
<label for="checkbox">Label</label>
\`\`\`
A checkbox is a square box that can be activated or deactivated when ticked.
Use checkboxes to select one or more options from a list of choices.
\`\`\`javascript
import { Checkbox } from '@react-spectrum/checkbox';
function Example() {
return <Checkbox>Label</Checkbox>;
}
\`\`\`
\`\`\`jsx
<Checkbox>Label</Checkbox>
\`\`\`
\`\`\`html
<input type="checkbox" id="checkbox" name="checkbox`;
const lessons = await prisma.lesson.createMany({
data: [
{
name: "Introduction to Markdown",
slug: "introduction-to-markdown",
description: "Learn the basics of Markdown",
content: mdxContent,
moduleId: module.id,
index: 1,
},
{
name: "Markdown Syntax",
slug: "markdown-syntax",
description: "Learn the syntax of Markdown",
content: mdxContent,
moduleId: module.id,
index: 2,
},
],
});
console.log("Seeding completed");
}
main()
.catch((e) => {
console.error(e);
process.exit(1);
})
.finally(async () => {
await prisma.$disconnect();
});