Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:02,420 --> 00:00:03,700
So let's continue working
2
00:00:03,700 --> 00:00:05,600
on that index.js file,
3
00:00:05,600 --> 00:00:08,417
in the posts folder on the AllPostsPage.
4
00:00:09,490 --> 00:00:10,840
Here the goal is simple,
5
00:00:10,840 --> 00:00:13,620
I wanna output all my posts.
6
00:00:13,620 --> 00:00:16,720
So later once we don't just have dummy posts,
7
00:00:16,720 --> 00:00:18,560
but actual data source,
8
00:00:18,560 --> 00:00:21,700
we will fetch all posts for this page,
9
00:00:21,700 --> 00:00:25,120
and then output them in some way here.
10
00:00:25,120 --> 00:00:27,760
Now, for the actual JSX code,
11
00:00:27,760 --> 00:00:30,480
for the detailed HTML structure,
12
00:00:30,480 --> 00:00:32,800
I'll again create a separate component,
13
00:00:32,800 --> 00:00:34,660
to keep my page component lean,
14
00:00:34,660 --> 00:00:37,090
and focused on data fetching.
15
00:00:37,090 --> 00:00:39,150
And therefore in the posts folder,
16
00:00:39,150 --> 00:00:43,833
in the components folder, I'll add an all-posts.js file.
17
00:00:44,690 --> 00:00:49,690
Now attached you'll also find out all-posts.module.css file,
18
00:00:49,840 --> 00:00:51,250
which you should download,
19
00:00:51,250 --> 00:00:55,790
and add next to the all-posts.js file.
20
00:00:55,790 --> 00:00:58,450
And then in this all-posts.js file,
21
00:00:58,450 --> 00:01:02,240
we define our all posts functional component,
22
00:01:02,240 --> 00:01:05,360
as we always do like this.
23
00:01:05,360 --> 00:01:10,060
And we can also already import the CSS styles,
24
00:01:10,060 --> 00:01:14,927
so important clauses from all-posts.module.css,
25
00:01:16,290 --> 00:01:20,930
and then work on the JSX code that should be returned here.
26
00:01:20,930 --> 00:01:25,160
And I'll keep this AllPosts page fairly simple.
27
00:01:25,160 --> 00:01:29,010
I'll just add a section which gets some styling,
28
00:01:29,010 --> 00:01:34,010
with classes.posts.
29
00:01:34,020 --> 00:01:35,880
And then I'll add a h1 tag,
30
00:01:35,880 --> 00:01:40,880
for the main title off this page where I just say All Posts,
31
00:01:41,500 --> 00:01:44,670
and then, I'll again use the PostsGrid,
32
00:01:44,670 --> 00:01:46,930
so we will reuse this component.
33
00:01:46,930 --> 00:01:49,830
And therefore, of course you also need to add this import.
34
00:01:50,760 --> 00:01:53,140
Now I do expect that I get posts,
35
00:01:53,140 --> 00:01:55,690
through props here from the page,
36
00:01:55,690 --> 00:01:58,650
because the page component should be responsible,
37
00:01:58,650 --> 00:02:01,970
for fetching and preparing the data.
38
00:02:01,970 --> 00:02:05,760
And hence on PostsGrid, we need to set that posts prop,
39
00:02:05,760 --> 00:02:09,949
and I'll just point at prop.posts for this.
40
00:02:09,949 --> 00:02:11,270
And that is already yet,
41
00:02:11,270 --> 00:02:14,093
it is a real simple component in the end.
42
00:02:15,820 --> 00:02:20,670
Now back on the posts page, on the AllPostsPage,
43
00:02:20,670 --> 00:02:25,250
I therefore, now wanna return the AllPosts component,
44
00:02:25,250 --> 00:02:26,700
we just worked on.
45
00:02:26,700 --> 00:02:29,620
And for this of course, also add to that import.
46
00:02:29,620 --> 00:02:31,050
And now here we again,
47
00:02:31,050 --> 00:02:34,423
need to prepare the posts that should be used.
48
00:02:35,410 --> 00:02:38,880
For the moment we can again use the dummy posts.
49
00:02:38,880 --> 00:02:43,350
So copy that DUMMY POSTS array from the starting page,
50
00:02:43,350 --> 00:02:46,840
but soon we will add a real data source.
51
00:02:46,840 --> 00:02:48,680
For the moment it's this though,
52
00:02:48,680 --> 00:02:50,530
so that's our dummy posts.
53
00:02:50,530 --> 00:02:53,233
And then here in AllPosts,
54
00:02:53,233 --> 00:02:57,790
I'll just pass in posts,
55
00:02:57,790 --> 00:03:00,013
and point at my dummy posts.
56
00:03:01,250 --> 00:03:03,500
And then with that done, if we save this
57
00:03:03,500 --> 00:03:06,980
and click on posts here, we're taken to that page.
58
00:03:06,980 --> 00:03:09,430
We got the navigation bar there as well,
59
00:03:09,430 --> 00:03:12,860
because we wrapped the layout around all pages,
60
00:03:12,860 --> 00:03:15,700
and we got our post grid here.
61
00:03:15,700 --> 00:03:18,350
So that is working just as it should,
62
00:03:18,350 --> 00:03:21,970
and that's the AllPostsPage finished.
63
00:03:21,970 --> 00:03:24,580
Now we got two pages left.
64
00:03:24,580 --> 00:03:27,450
We got the page for individual posts,
65
00:03:27,450 --> 00:03:31,040
if we click on it and we got this contact page.
66
00:03:31,040 --> 00:03:33,340
Now we could start with either of the two,
67
00:03:33,340 --> 00:03:37,180
but I would say let's start with the post detailed page,
68
00:03:37,180 --> 00:03:38,980
so that when we click on a post,
69
00:03:38,980 --> 00:03:43,730
we load a page and we displayed the actual post content here
70
00:03:43,730 --> 00:03:47,000
because that will then also get us closer,
71
00:03:47,000 --> 00:03:49,560
to setting up an actual data source,
72
00:03:49,560 --> 00:03:51,970
and to setting up actual posts,
73
00:03:51,970 --> 00:03:55,630
which we can then fetch and pre-render and so on,
74
00:03:55,630 --> 00:03:57,693
so that's there for what we'll do next.
5727
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.