Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,804 --> 00:00:04,040
So let's continue working on
2
00:00:04,040 --> 00:00:06,410
the featured posts now,
3
00:00:06,410 --> 00:00:09,940
now that we added the navigation and so on.
4
00:00:09,940 --> 00:00:12,139
The goal of the featured posts component
5
00:00:12,139 --> 00:00:15,432
is to output some posts which we,
6
00:00:15,432 --> 00:00:18,828
as the owner of the block, marked as featured.
7
00:00:18,828 --> 00:00:20,816
Now, we will add posts
8
00:00:20,816 --> 00:00:23,747
and mark them as featured in a later step
9
00:00:23,747 --> 00:00:25,517
but we can already start
10
00:00:25,517 --> 00:00:29,358
with outputting some dummy posts here for the moment.
11
00:00:29,358 --> 00:00:31,059
Therefore, in featured posts
12
00:00:31,059 --> 00:00:35,178
I'll again create a basic component, featured posts
13
00:00:35,178 --> 00:00:38,227
and, you've guessed it, we will export it,
14
00:00:38,227 --> 00:00:40,360
like we always did.
15
00:00:40,360 --> 00:00:43,331
Now we have a featured posts module CSS file
16
00:00:43,331 --> 00:00:46,301
and we will need it so we will import classes
17
00:00:46,301 --> 00:00:51,301
from that featured posts module CSS file already.
18
00:00:52,141 --> 00:00:55,610
And then here, in that featured posts component
19
00:00:55,610 --> 00:00:58,411
I again want to create another section
20
00:00:58,411 --> 00:01:03,130
which will receive a class of latest,
21
00:01:03,130 --> 00:01:05,950
because that's one of the classes that I pre-defined
22
00:01:05,950 --> 00:01:07,658
in the CSS file.
23
00:01:07,658 --> 00:01:12,658
Then a heading for this section where I say featured posts
24
00:01:13,104 --> 00:01:18,104
and then below that a list of posts, or a grid of posts.
25
00:01:19,240 --> 00:01:22,677
And for this I'll actually create a separate component.
26
00:01:22,677 --> 00:01:24,080
Why?
27
00:01:24,080 --> 00:01:28,635
Because we will then use that same list, or grid,
28
00:01:28,635 --> 00:01:32,369
as it will actually be on the all posts page.
29
00:01:32,369 --> 00:01:36,895
On both the starting page in the featured posts component,
30
00:01:36,895 --> 00:01:39,338
as well as on the all posts page,
31
00:01:39,338 --> 00:01:43,280
I want to output posts in the same way.
32
00:01:43,280 --> 00:01:48,280
I want to render a grid of post cards, so of post items.
33
00:01:48,770 --> 00:01:50,295
I want to render those as a grid
34
00:01:50,295 --> 00:01:52,730
and these items then should be clickable
35
00:01:52,730 --> 00:01:55,025
and take us to the individual post.
36
00:01:55,025 --> 00:01:58,455
The only difference is the number of posts
37
00:01:58,455 --> 00:02:01,095
and the actual posts that are being rendered,
38
00:02:01,095 --> 00:02:05,800
but the way that they are presented will always be the same.
39
00:02:05,800 --> 00:02:08,085
Hence we can create a reusable component for that
40
00:02:08,085 --> 00:02:09,866
and that is what I will do.
41
00:02:09,866 --> 00:02:13,325
In the components folder I'll create a new sub-folder
42
00:02:13,325 --> 00:02:15,154
which I'll name posts,
43
00:02:15,154 --> 00:02:19,495
which should hold all the posts specific components.
44
00:02:19,495 --> 00:02:22,255
And we could argue that featured posts
45
00:02:22,255 --> 00:02:24,935
is also a posts specific component
46
00:02:24,935 --> 00:02:27,556
but it's even more specific to the home page
47
00:02:27,556 --> 00:02:30,020
because we only use it there,
48
00:02:30,020 --> 00:02:32,603
which is why I keep it in the home page folder.
49
00:02:33,536 --> 00:02:35,525
Now, in that posts folder
50
00:02:35,525 --> 00:02:39,785
I'll add a posts dash grid component file though
51
00:02:39,785 --> 00:02:42,985
which will then render this grid of posts.
52
00:02:42,985 --> 00:02:45,797
And now for that posts grid,
53
00:02:45,797 --> 00:02:50,176
you already find a posts grid module CSS file attached
54
00:02:50,176 --> 00:02:52,545
which we will need in a second,
55
00:02:52,545 --> 00:02:53,925
so you can download that
56
00:02:53,925 --> 00:02:58,210
and add it in the posts grid JavaScript file.
57
00:02:58,210 --> 00:03:03,210
Now you'll also find attached a post item module CSS file
58
00:03:03,630 --> 00:03:06,142
and you can download and add that as well,
59
00:03:06,142 --> 00:03:08,420
also in the posts folder
60
00:03:08,420 --> 00:03:13,420
because we will also create a post item JS file next to that
61
00:03:13,540 --> 00:03:16,144
which will hold a single post item.
62
00:03:16,144 --> 00:03:20,170
The post grid will render a couple of post items
63
00:03:20,170 --> 00:03:23,300
and I'll split the grid and the actual items
64
00:03:23,300 --> 00:03:25,020
into separate components
65
00:03:25,020 --> 00:03:28,308
to keep every component lean and maintainable.
66
00:03:28,308 --> 00:03:31,950
Let's start working on the posts grid component though.
67
00:03:31,950 --> 00:03:35,785
In that posts grid file I'll add a function,
68
00:03:35,785 --> 00:03:38,929
posts grid, which is my default component function
69
00:03:38,929 --> 00:03:42,347
which, as always, is then just exported.
70
00:03:42,347 --> 00:03:44,070
Of course, by the way,
71
00:03:44,070 --> 00:03:47,175
you could create a snippet for this in Visual Studio Code
72
00:03:47,175 --> 00:03:48,301
to save some time,
73
00:03:48,301 --> 00:03:50,987
but here I'll just write it manually all the time
74
00:03:50,987 --> 00:03:54,420
and then in the posts grid component
75
00:03:54,420 --> 00:03:56,440
we want to return to JSX code.
76
00:03:56,440 --> 00:03:58,488
That should be output here.
77
00:03:58,488 --> 00:04:02,054
Now, the JSX code is, again, very simple here.
78
00:04:02,054 --> 00:04:06,360
It will be an unordered list of posts items.
79
00:04:06,360 --> 00:04:09,490
Now the data for those posts
80
00:04:09,490 --> 00:04:12,920
should be received from outside, though.
81
00:04:12,920 --> 00:04:14,916
I do expect that I get props here
82
00:04:14,916 --> 00:04:19,916
and in my props I want to get a special posts prop.
83
00:04:22,550 --> 00:04:25,830
Now, the props name is up to you as its your component
84
00:04:25,830 --> 00:04:29,440
you just need to make sure that you then use that prop name
85
00:04:29,440 --> 00:04:32,263
for passing data into this component.
86
00:04:32,263 --> 00:04:35,899
So then I what to output my posts dynamically here
87
00:04:35,899 --> 00:04:40,857
by mapping every post into a post item
88
00:04:42,265 --> 00:04:44,653
and we have yet to add this component,
89
00:04:44,653 --> 00:04:46,720
but that's my goal here.
90
00:04:46,720 --> 00:04:48,325
I want to output a list of posts
91
00:04:48,325 --> 00:04:52,703
where I map my posts data into post item components.
92
00:04:52,703 --> 00:04:54,936
That's the goal here.
93
00:04:54,936 --> 00:04:59,660
Now, we will need to import post item for that
94
00:04:59,660 --> 00:05:02,175
from the post item file we just added
95
00:05:02,175 --> 00:05:04,787
and this file is empty right now,
96
00:05:04,787 --> 00:05:06,770
but we will work on that soon,
97
00:05:06,770 --> 00:05:08,748
and we'll also need some styling
98
00:05:08,748 --> 00:05:10,652
so I'll import some classes from
99
00:05:10,652 --> 00:05:15,652
dot slash posts grid dot module dot CSS.
100
00:05:17,160 --> 00:05:20,927
And that is that posts grid CSS file for this component
101
00:05:20,927 --> 00:05:22,990
which has a class
102
00:05:22,990 --> 00:05:25,095
which should be added to the unordered list.
103
00:05:25,095 --> 00:05:27,612
There I want to add the grid class,
104
00:05:27,612 --> 00:05:29,705
which is defined in posts grid,
105
00:05:29,705 --> 00:05:32,553
and there we use the CSS grid feature
106
00:05:32,553 --> 00:05:36,230
to render some grid columns.
107
00:05:36,230 --> 00:05:38,040
Okay, so that's that.
108
00:05:38,040 --> 00:05:41,720
Now let's work on the post item, on the post item component
109
00:05:41,720 --> 00:05:45,673
which outputs an individual item in that grid of posts.
8559
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.