Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,409 --> 00:00:03,340
So it's time to move away
2
00:00:03,340 --> 00:00:05,630
from those dummy posts.
3
00:00:05,630 --> 00:00:08,260
That of course, brings up one question,
4
00:00:08,260 --> 00:00:12,320
where do we wanna store our actual posts?
5
00:00:12,320 --> 00:00:16,610
And one pretty obvious choice would be a database,
6
00:00:16,610 --> 00:00:21,610
something like Firebase or a MongoDB or SQL database.
7
00:00:21,730 --> 00:00:23,810
And there is nothing wrong with that.
8
00:00:23,810 --> 00:00:27,190
We could do that, but for a blog like this
9
00:00:27,190 --> 00:00:31,670
which is owned by us, where we write those blog posts,
10
00:00:31,670 --> 00:00:35,550
there also is another very nice solution.
11
00:00:35,550 --> 00:00:39,910
We could use our file system as a data source
12
00:00:39,910 --> 00:00:43,850
because we don't need to write to our blog posts.
13
00:00:43,850 --> 00:00:46,360
I mean, we have to write them at some point
14
00:00:46,360 --> 00:00:47,950
but then once they're done,
15
00:00:47,950 --> 00:00:51,120
they are a data source from which we only fetch data.
16
00:00:51,120 --> 00:00:53,860
We only use them to load blog posts,
17
00:00:53,860 --> 00:00:55,060
users on the website
18
00:00:55,060 --> 00:00:57,780
can't interact with them to change them.
19
00:00:57,780 --> 00:01:01,160
So once they exist, we might occasionally update.
20
00:01:01,160 --> 00:01:02,350
But whenever we do that,
21
00:01:02,350 --> 00:01:06,120
we as an owner dive directly into those blog posts
22
00:01:06,120 --> 00:01:09,200
but the files themselves are then only fetched
23
00:01:09,200 --> 00:01:11,210
by our application.
24
00:01:11,210 --> 00:01:15,820
So if we use our local file system here, our project folder,
25
00:01:15,820 --> 00:01:19,620
we don't have to set up an extra database and pay for it.
26
00:01:19,620 --> 00:01:22,350
We don't have to do all that wire up work
27
00:01:22,350 --> 00:01:24,820
and that can be pretty nice.
28
00:01:24,820 --> 00:01:26,760
And therefore, a quite common approach
29
00:01:26,760 --> 00:01:30,560
is to add a new folder in your project folder,
30
00:01:30,560 --> 00:01:33,130
which could be named content
31
00:01:33,130 --> 00:01:34,700
but that name is totally up to you.
32
00:01:34,700 --> 00:01:38,240
It doesn't have to be named content and in there,
33
00:01:38,240 --> 00:01:41,160
we could have a sub folder named, posts
34
00:01:41,160 --> 00:01:44,290
if we would have different kinds of content
35
00:01:44,290 --> 00:01:47,840
or if we don't have that, we get rid of that folder,
36
00:01:47,840 --> 00:01:50,510
and instead of a content post folder,
37
00:01:50,510 --> 00:01:53,723
we just directly add a post folder in the project.
38
00:01:55,050 --> 00:01:56,430
Now, the idea is that,
39
00:01:56,430 --> 00:02:00,360
in that post folder, we store our posts.
40
00:02:00,360 --> 00:02:03,343
And what do I mean with store our posts?
41
00:02:04,380 --> 00:02:05,560
Well, keep in mind
42
00:02:05,560 --> 00:02:09,180
that we will write our posts with markdown,
43
00:02:09,180 --> 00:02:11,503
so with that markdown syntax.
44
00:02:12,350 --> 00:02:14,460
Hence I'll add a new file in there,
45
00:02:14,460 --> 00:02:19,203
let's say, the getting-started-with-nextjs.md file.
46
00:02:22,360 --> 00:02:24,823
MD stands for markdown.
47
00:02:25,760 --> 00:02:28,840
So this is a markdown file, which I added here.
48
00:02:28,840 --> 00:02:31,940
And in there, we can write markdown code.
49
00:02:31,940 --> 00:02:35,350
You can also install extra extensions that help you
50
00:02:35,350 --> 00:02:37,320
with writing markdown code.
51
00:02:37,320 --> 00:02:40,700
In visual studio code, if you search for markdown,
52
00:02:40,700 --> 00:02:42,870
there you can install extra support,
53
00:02:42,870 --> 00:02:44,360
but I don't even have that,
54
00:02:44,360 --> 00:02:46,443
I am happy to write it like this.
55
00:02:47,640 --> 00:02:50,750
Now in here, we kind of write that markdown code like,
56
00:02:50,750 --> 00:02:52,870
this is a title,
57
00:02:52,870 --> 00:02:56,850
this is some regular text with a link.
58
00:02:58,220 --> 00:03:02,023
That is something could write here as content.
59
00:03:03,480 --> 00:03:05,510
However, if you take a closer look
60
00:03:05,510 --> 00:03:08,960
at our pages and our different components,
61
00:03:08,960 --> 00:03:12,790
you might see that just content is not enough.
62
00:03:12,790 --> 00:03:15,960
We also rely on an excerpt and a date
63
00:03:15,960 --> 00:03:20,960
and a title and image for outputting all our posts.
64
00:03:21,010 --> 00:03:24,840
So we need to add metadata to our posts.
65
00:03:24,840 --> 00:03:26,920
And the great thing about markdown,
66
00:03:26,920 --> 00:03:29,100
is that you can easily combine it
67
00:03:29,100 --> 00:03:33,410
with a concept called gray matter, which is just metadata.
68
00:03:33,410 --> 00:03:35,860
You add to your markdown file.
69
00:03:35,860 --> 00:03:39,326
You add that by adding free dashes, opening and closing,
70
00:03:39,326 --> 00:03:43,230
so to say, above your content.
71
00:03:43,230 --> 00:03:44,890
So here we have free dashes
72
00:03:44,890 --> 00:03:47,610
and between those free dash separators,
73
00:03:47,610 --> 00:03:50,320
we can add our metadata
74
00:03:50,320 --> 00:03:54,820
for this markdown file as key value pairs basically,
75
00:03:54,820 --> 00:03:57,803
in Yaml format to be precise.
76
00:03:59,190 --> 00:04:01,140
And you can look up Yaml formats
77
00:04:01,140 --> 00:04:03,370
to see what's allowed in here.
78
00:04:03,370 --> 00:04:05,660
And for example, we can set a title here,
79
00:04:05,660 --> 00:04:09,250
to, this is the post title,
80
00:04:09,250 --> 00:04:13,627
or in this case, probably getting started with nextjS.
81
00:04:24,580 --> 00:04:28,088
And we can also wrap that in quotes to make it clear that,
82
00:04:28,088 --> 00:04:30,220
that's a string.
83
00:04:30,220 --> 00:04:32,460
It's technically not always required
84
00:04:32,460 --> 00:04:35,060
but can be required sometimes if Yaml
85
00:04:35,060 --> 00:04:39,033
is not able to find out which data type it is otherwise.
86
00:04:39,980 --> 00:04:43,030
Here you could also add an author if you need that.
87
00:04:43,030 --> 00:04:45,652
I don't have it in this block since it's only my blog
88
00:04:45,652 --> 00:04:48,300
and I'm the only author of all those posts
89
00:04:48,300 --> 00:04:50,600
but you could add a author field here as well
90
00:04:50,600 --> 00:04:52,763
and then fetch and render that later.
91
00:04:53,810 --> 00:04:56,040
Now what we'll need is a image though,
92
00:04:56,040 --> 00:04:58,730
we will definitely need that.
93
00:04:58,730 --> 00:05:01,790
And here I'll just have my getting-started
94
00:05:03,378 --> 00:05:06,640
nextjs.png image file here.
95
00:05:06,640 --> 00:05:08,220
So this image file, which I added
96
00:05:08,220 --> 00:05:11,340
in the images posts folder before.
97
00:05:11,340 --> 00:05:14,370
And as a side note to connect everything correctly,
98
00:05:14,370 --> 00:05:16,950
and use the already existing structure
99
00:05:16,950 --> 00:05:18,870
in the public images folder,
100
00:05:18,870 --> 00:05:20,010
you should make sure
101
00:05:20,010 --> 00:05:24,150
that your posts markdown file has a file name
102
00:05:24,150 --> 00:05:27,610
that matches one of the folder names in that posts folder
103
00:05:27,610 --> 00:05:29,300
in the images folder
104
00:05:29,300 --> 00:05:32,150
because we'll then later connect all that data
105
00:05:32,150 --> 00:05:35,410
such that we fetch the image we specify here
106
00:05:35,410 --> 00:05:38,040
from a equally named folder
107
00:05:38,040 --> 00:05:40,920
in the public images posts folder.
108
00:05:40,920 --> 00:05:43,070
So you should make sure that this is equal.
109
00:05:44,760 --> 00:05:48,810
Then here, we can also add an excerpt
110
00:05:48,810 --> 00:05:53,810
and I'll just quickly grab my dummy excerpt here
111
00:05:53,910 --> 00:05:56,080
which I wrote down before
112
00:05:56,080 --> 00:06:00,920
from the index.js file and add that as an excerpt here.
113
00:06:00,920 --> 00:06:02,370
I didn't add a line break here.
114
00:06:02,370 --> 00:06:06,170
That's just my IDE, which is kind of showing a line break.
115
00:06:06,170 --> 00:06:08,423
It's one long inline text.
116
00:06:10,250 --> 00:06:13,840
And I will now also add a isFeatured key here
117
00:06:13,840 --> 00:06:15,700
and set this to true.
118
00:06:15,700 --> 00:06:19,410
So Boolean values are also allowed here.
119
00:06:19,410 --> 00:06:21,130
We will then later use that
120
00:06:21,130 --> 00:06:25,223
for selecting just the featured posts for the starting page.
121
00:06:26,140 --> 00:06:28,280
So that's now extra metadata
122
00:06:28,280 --> 00:06:31,350
and that's the actual post content.
123
00:06:31,350 --> 00:06:33,430
And we can write files like this,
124
00:06:33,430 --> 00:06:35,130
and we can also fetch data
125
00:06:35,130 --> 00:06:38,311
from such files and split it in metadata and content.
126
00:06:38,311 --> 00:06:41,650
All of that is possible with ease
127
00:06:41,650 --> 00:06:45,440
and therefore that will be our data source here.
128
00:06:45,440 --> 00:06:49,440
So now with that, all save that markdown file.
129
00:06:49,440 --> 00:06:50,870
And I will now also get rid
130
00:06:50,870 --> 00:06:54,930
of the other dummy post folders in the images folder
131
00:06:54,930 --> 00:06:57,660
and just keep one of those folders around
132
00:06:57,660 --> 00:07:00,340
for that markdown file we just added.
133
00:07:00,340 --> 00:07:05,250
And now the goal is to kind of use our posts folder
134
00:07:05,250 --> 00:07:10,250
as a data source to generate all required single
135
00:07:10,650 --> 00:07:13,610
post files based on the number of post files
136
00:07:13,610 --> 00:07:18,190
in the post folder to load the featured posts from there,
137
00:07:18,190 --> 00:07:20,160
so to go through all the posts
138
00:07:20,160 --> 00:07:23,320
and selected the featured posts for the starting page
139
00:07:23,320 --> 00:07:28,130
and to load all the posts for the all posts page.
140
00:07:28,130 --> 00:07:31,133
And that's what we're going to do in the next lecture.
11019
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.