Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:02,100 --> 00:00:04,230
Now the question is how do we get started
2
00:00:04,230 --> 00:00:05,689
with this project though?
3
00:00:05,689 --> 00:00:07,490
And there are different ways
4
00:00:07,490 --> 00:00:10,130
it's of course, up to you, which approach you prefer,
5
00:00:10,130 --> 00:00:14,110
but I personally like to get started with my pages
6
00:00:14,110 --> 00:00:17,040
that gives the project a general structure,
7
00:00:17,040 --> 00:00:19,510
and I can then plan my other components
8
00:00:19,510 --> 00:00:21,980
around those pages which we need.
9
00:00:21,980 --> 00:00:26,370
So I'll start in this pages folder and here for this block,
10
00:00:26,370 --> 00:00:27,880
we need a couple of pages.
11
00:00:27,880 --> 00:00:29,720
We need the starting page,
12
00:00:29,720 --> 00:00:32,369
which shows the featured blog posts
13
00:00:32,369 --> 00:00:34,930
and our little welcome screen.
14
00:00:34,930 --> 00:00:36,800
We need the contact page,
15
00:00:36,800 --> 00:00:40,640
which shows that form users can fill out.
16
00:00:40,640 --> 00:00:44,200
We need the page for all the blog posts
17
00:00:44,200 --> 00:00:48,240
and we need the individual blog post page.
18
00:00:48,240 --> 00:00:50,070
And therefore in the pages folder,
19
00:00:50,070 --> 00:00:52,350
I'll start with the starting page
20
00:00:52,350 --> 00:00:56,565
by adding an index.js file in the pages folder.
21
00:00:56,565 --> 00:01:01,565
Now in there, we can create our homepage component function
22
00:01:01,790 --> 00:01:05,950
and export that as a default here, like this.
23
00:01:05,950 --> 00:01:07,770
And I'll copy that basic code
24
00:01:07,770 --> 00:01:10,330
because I'll create functions in the same way
25
00:01:10,330 --> 00:01:12,550
in the other pages.
26
00:01:12,550 --> 00:01:16,220
And for example, in the contact page, we also need that
27
00:01:16,220 --> 00:01:19,260
and hence we can add a contact.js file
28
00:01:19,260 --> 00:01:21,340
here in the pages folder.
29
00:01:21,340 --> 00:01:23,680
Now you'll learnt that the alternative
30
00:01:23,680 --> 00:01:25,800
would be to add a contact folder
31
00:01:25,800 --> 00:01:28,110
with the index.js file in there.
32
00:01:28,110 --> 00:01:30,230
It's up to you, which approach you prefer.
33
00:01:30,230 --> 00:01:33,970
I will go for the context for the contact.js file
34
00:01:33,970 --> 00:01:37,430
and just add my component in there,
35
00:01:37,430 --> 00:01:40,813
the contact page, like this.
36
00:01:42,180 --> 00:01:45,970
Then we also have our posts specific pages.
37
00:01:45,970 --> 00:01:47,930
And for that I'll create a sub folder
38
00:01:47,930 --> 00:01:50,960
because there I'll also need a nested route
39
00:01:50,960 --> 00:01:53,140
with a dynamic segment.
40
00:01:53,140 --> 00:01:55,300
However, I'll start with a different page,
41
00:01:55,300 --> 00:01:58,360
a different route, and that's the all posts page
42
00:01:58,360 --> 00:02:00,640
for this we could add a posts folder
43
00:02:00,640 --> 00:02:03,530
and then an index.js file in there.
44
00:02:03,530 --> 00:02:08,160
And that page will then be loaded for requests targeting
45
00:02:08,160 --> 00:02:12,430
our domain slash posts slash nothing.
46
00:02:12,430 --> 00:02:17,430
So here we have the all posts page, like this.
47
00:02:20,830 --> 00:02:23,640
Then we have the page for a single post.
48
00:02:23,640 --> 00:02:25,490
So when we click on a post,
49
00:02:25,490 --> 00:02:28,000
the page that shows that single post
50
00:02:28,000 --> 00:02:30,930
and that page is dynamic.
51
00:02:30,930 --> 00:02:33,573
It should have a dynamic parameter in the URL,
52
00:02:34,530 --> 00:02:39,530
which identifies that post, something like the post ID.
53
00:02:39,590 --> 00:02:42,810
And therefore we could add id.js file
54
00:02:42,810 --> 00:02:44,680
with id in square brackets
55
00:02:44,680 --> 00:02:48,480
because you'll learnt that this sets up a dynamic page
56
00:02:48,480 --> 00:02:52,320
in next.js which is loaded for different requests
57
00:02:52,320 --> 00:02:55,580
with different IDs in the URL.
58
00:02:55,580 --> 00:02:58,330
And we can then extract the concrete value
59
00:02:58,330 --> 00:03:00,780
that was provided for a given request
60
00:03:00,780 --> 00:03:03,430
from inside that page.
61
00:03:03,430 --> 00:03:07,240
That would work, but I don't wanna work with an ID here.
62
00:03:07,240 --> 00:03:09,230
Now, of course the identifier name here
63
00:03:09,230 --> 00:03:10,620
is totally up to you,
64
00:03:10,620 --> 00:03:13,434
but you should name it such that it reflects
65
00:03:13,434 --> 00:03:17,050
which kind of value you'll extract.
66
00:03:17,050 --> 00:03:21,020
And I don't want an ID here because if we had an ID,
67
00:03:21,020 --> 00:03:22,940
if we do that for a second,
68
00:03:22,940 --> 00:03:25,310
then we would load a single post
69
00:03:25,310 --> 00:03:30,310
for something like slash post slash p1, p2, p3 and so on.
70
00:03:31,000 --> 00:03:34,690
If p1, p2, p3 are our IDs.
71
00:03:34,690 --> 00:03:36,810
And whilst this would work,
72
00:03:36,810 --> 00:03:39,050
it's not very human readable
73
00:03:39,050 --> 00:03:41,693
and also not search engine friendly.
74
00:03:42,530 --> 00:03:45,860
It would be better to have URLs
75
00:03:45,860 --> 00:03:50,860
like /posts/getting-started-with-nextjs.
76
00:03:51,390 --> 00:03:54,860
If our URL would look something like this.
77
00:03:54,860 --> 00:03:58,410
Now, this thing here, is called a slug.
78
00:03:58,410 --> 00:04:00,730
That's what we typically call a slug.
79
00:04:00,730 --> 00:04:02,960
It's also a unique identifier,
80
00:04:02,960 --> 00:04:05,790
we could call it a unique ID therefore
81
00:04:05,790 --> 00:04:07,140
but it is called a slug
82
00:04:07,140 --> 00:04:09,820
and it's basically a human readable sentence
83
00:04:09,820 --> 00:04:12,990
without white space, without special characters.
84
00:04:12,990 --> 00:04:16,940
Simply with words separated by dashes.
85
00:04:16,940 --> 00:04:21,940
And hence here, I want to extract such a slug from my URL
86
00:04:23,260 --> 00:04:27,540
and I expect that I do get these slug identifiers
87
00:04:27,540 --> 00:04:32,420
for the individual posts to have these human readable
88
00:04:32,420 --> 00:04:37,420
and search engine friendly URLs in the end.
89
00:04:37,580 --> 00:04:41,790
That is then the single post page
90
00:04:41,790 --> 00:04:44,470
or the post detailed page.
91
00:04:44,470 --> 00:04:45,823
However you wanna call it.
92
00:04:47,120 --> 00:04:52,120
Now, these are the four main pages which this project needs.
93
00:04:52,660 --> 00:04:56,950
Of course, definitely feel free to add more pages.
94
00:04:56,950 --> 00:04:59,430
It's also your project after all,
95
00:04:59,430 --> 00:05:01,750
and you can enhance it however you want,
96
00:05:01,750 --> 00:05:04,110
but these are the four pages
97
00:05:04,110 --> 00:05:08,373
with which I wanna get started in this project here.
7506
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.