All language subtitles for 008 Adding A Post Grid & Post Items_Downloadly.ir_en

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian Download
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:02,160 --> 00:00:05,030 In this PostItem component, 2 00:00:05,030 --> 00:00:08,900 or in this file we again create our component function 3 00:00:08,900 --> 00:00:12,530 and as always export that of course. 4 00:00:12,530 --> 00:00:15,040 And then we define the structure, 5 00:00:15,040 --> 00:00:17,343 the markup of a single PostItem. 6 00:00:18,670 --> 00:00:21,340 And for me a PostItem will be a list item 7 00:00:21,340 --> 00:00:24,560 which should make sense because we're in an unordered list. 8 00:00:24,560 --> 00:00:28,910 So having a list item is a good choice typically 9 00:00:29,760 --> 00:00:33,060 and then the entire item should be clickable. 10 00:00:33,060 --> 00:00:38,060 Therefore I'll import link from next/link 11 00:00:38,280 --> 00:00:40,310 because of course I wanna use this link 12 00:00:40,310 --> 00:00:42,930 to still stay in the single page application 13 00:00:42,930 --> 00:00:45,940 use pre-fetching and all those things. 14 00:00:45,940 --> 00:00:50,940 And I'll then add a link here with a anchor tag inside 15 00:00:51,170 --> 00:00:55,200 since I'll have a more complex HTML structure in that link. 16 00:00:55,200 --> 00:00:57,310 And as I mentioned a couple of minutes ago 17 00:00:57,310 --> 00:00:59,870 you then need to bring your own anchor tag 18 00:00:59,870 --> 00:01:04,269 to tell link that it should still render anchor tag. 19 00:01:04,269 --> 00:01:08,240 And then regarding that more complex structure in here 20 00:01:08,240 --> 00:01:13,240 I wanna have a div which will hold a post-image 21 00:01:13,510 --> 00:01:17,392 which has at the top of this postcard and below that 22 00:01:17,392 --> 00:01:19,880 another div which will hold the content, 23 00:01:19,880 --> 00:01:22,540 the title, the date, and a short excerpt, 24 00:01:22,540 --> 00:01:23,543 which we wanna show. 25 00:01:25,240 --> 00:01:28,740 Now inside that first div idea for output my image. 26 00:01:28,740 --> 00:01:32,430 And we will soon add the source and everything else. 27 00:01:32,430 --> 00:01:34,600 And then the second div here 28 00:01:34,600 --> 00:01:39,400 they're all add a h3 tag with the title of the post. 29 00:01:39,400 --> 00:01:43,460 Then a time element, which outputs the time 30 00:01:43,460 --> 00:01:48,460 something like July 13th, 2022 31 00:01:48,740 --> 00:01:50,110 something like that will be output here. 32 00:01:50,110 --> 00:01:54,913 And then a paragraph with the expert text of that post. 33 00:01:56,590 --> 00:01:59,400 And of course at the moment it's just dummy data 34 00:01:59,400 --> 00:02:02,253 soon it will be actual data. 35 00:02:03,420 --> 00:02:05,800 Now, before we continue on the data, 36 00:02:05,800 --> 00:02:09,199 let's continue with the styling actually 37 00:02:09,199 --> 00:02:12,750 for this again I will again import classes 38 00:02:12,750 --> 00:02:16,860 from that PostItem.module.css file 39 00:02:16,860 --> 00:02:20,190 which I provided to you in the last lecture. 40 00:02:20,190 --> 00:02:24,280 And then we add a class to the list item, the post-class. 41 00:02:24,280 --> 00:02:27,480 We also add a class to the div, which wraps the image. 42 00:02:27,480 --> 00:02:29,523 It's the image class. 43 00:02:30,590 --> 00:02:34,370 And we add a class to this div which wraps the content. 44 00:02:34,370 --> 00:02:36,733 It's the content class. 45 00:02:38,090 --> 00:02:40,190 Now let's work on the data. 46 00:02:40,190 --> 00:02:42,790 The data for a single PostItem of course 47 00:02:42,790 --> 00:02:45,740 is not hard-coded in the PostItem. 48 00:02:45,740 --> 00:02:49,270 We will also not fetch it from inside the PostItem 49 00:02:49,270 --> 00:02:52,570 with user fact and fetch or anything like that. 50 00:02:52,570 --> 00:02:56,900 Instead I expect that I get it through props so that 51 00:02:56,900 --> 00:03:00,700 in the post-grid component where we rendered a PostItems 52 00:03:00,700 --> 00:03:02,960 and where we have a list of posts 53 00:03:02,960 --> 00:03:05,930 which probably is a list of JavaScript objects 54 00:03:05,930 --> 00:03:09,770 with the post data where we then just forward 55 00:03:09,770 --> 00:03:13,050 that data we have here already into the PostItem, 56 00:03:13,050 --> 00:03:15,580 through props, that's the goal. 57 00:03:15,580 --> 00:03:19,800 So in PostItem, we can expect a couple of props 58 00:03:19,800 --> 00:03:22,430 and I will use object de-structuring 59 00:03:22,430 --> 00:03:27,430 to pull those prop properties into separate constants. 60 00:03:28,330 --> 00:03:29,810 Now it is your component. 61 00:03:29,810 --> 00:03:33,350 It is up to you how you expect to get data, 62 00:03:33,350 --> 00:03:37,510 how you expect to pass data to this component. 63 00:03:37,510 --> 00:03:39,110 If you wanna have one prop 64 00:03:39,110 --> 00:03:43,660 which carries the entire post data or multiple props 65 00:03:43,660 --> 00:03:46,110 and I will go for one prop here 66 00:03:46,110 --> 00:03:51,110 a post prop on props, and I'll destructure that. 67 00:03:51,390 --> 00:03:53,860 So I expect that I get a post prop 68 00:03:53,860 --> 00:03:56,780 and that post prop holds a JavaScript object 69 00:03:56,780 --> 00:04:00,030 with multiple properties which describe the post 70 00:04:00,030 --> 00:04:02,570 and I'm now pulling out those properties 71 00:04:02,570 --> 00:04:06,723 into separate constants with object de-structuring here. 72 00:04:07,590 --> 00:04:08,933 And we could, for example, 73 00:04:08,933 --> 00:04:12,120 expect a title, a image, an excerpt, 74 00:04:12,120 --> 00:04:15,793 which is a short summary text basically for the post, 75 00:04:15,793 --> 00:04:20,170 the date, and also the slug of that post. 76 00:04:20,170 --> 00:04:23,960 So the path to the post so to say 77 00:04:23,960 --> 00:04:27,310 the unique identifier of the post. 78 00:04:27,310 --> 00:04:30,530 And that's the data with which we can break down there 79 00:04:30,530 --> 00:04:31,363 for example, 80 00:04:31,363 --> 00:04:35,681 for the title we can now output the title, 81 00:04:35,681 --> 00:04:37,793 which we extract here. 82 00:04:38,760 --> 00:04:41,170 Now for the date, we can also output this 83 00:04:41,170 --> 00:04:43,000 but I wanna format it first, 84 00:04:43,000 --> 00:04:45,150 make it more human readable 85 00:04:45,150 --> 00:04:48,600 because the date which we get here as a prop 86 00:04:48,600 --> 00:04:52,350 will be in a more machine readable format. 87 00:04:52,350 --> 00:04:56,050 All the human readable but not nicely formatted. 88 00:04:56,050 --> 00:04:58,910 And I wanna make sure that it is nicely formatted 89 00:04:58,910 --> 00:05:03,910 hence here I will actually create a formatted date constant, 90 00:05:04,490 --> 00:05:06,860 where I create a new date object 91 00:05:06,860 --> 00:05:09,070 and pass my date prop to it, 92 00:05:09,070 --> 00:05:13,100 so that a new date JavaScript object is constructed 93 00:05:13,100 --> 00:05:16,480 based on that date value, which I receive here. 94 00:05:16,480 --> 00:05:18,660 And hence of course, we have to make sure 95 00:05:18,660 --> 00:05:21,610 that date holds a value which can be used 96 00:05:21,610 --> 00:05:23,450 with this constructor function 97 00:05:23,450 --> 00:05:26,650 and we will make sure that this the case. 98 00:05:26,650 --> 00:05:29,030 And then on that date object, 99 00:05:29,030 --> 00:05:31,350 we can call toLocalDateString 100 00:05:32,660 --> 00:05:34,090 and pass en-US 101 00:05:34,090 --> 00:05:37,010 as a first argument and a configuration object 102 00:05:37,010 --> 00:05:41,883 as a second argument to output a human readable date. 103 00:05:42,920 --> 00:05:47,920 And here I'll set day to numeric, I'll set month to long 104 00:05:49,370 --> 00:05:53,890 so that if it's January we don't output 01 or just 1 105 00:05:53,890 --> 00:05:57,240 but instead January as a text 106 00:05:57,240 --> 00:06:01,563 and then year to numeric as well. 107 00:06:03,150 --> 00:06:05,030 Okay so now we've got that formatted date 108 00:06:05,030 --> 00:06:06,900 and it's now this formatted date 109 00:06:06,900 --> 00:06:08,890 which I wanna use down here. 110 00:06:08,890 --> 00:06:11,623 So here we output the formatted date. 111 00:06:13,270 --> 00:06:18,270 Now for the excerpt we wanna output the well excerpt 112 00:06:18,380 --> 00:06:20,860 which we're getting as a prop. 113 00:06:20,860 --> 00:06:22,550 So I'll put excerpt here, 114 00:06:22,550 --> 00:06:25,930 this excerpt and now for the image, 115 00:06:25,930 --> 00:06:30,010 the image needs a source property. 116 00:06:30,010 --> 00:06:32,590 It needs an alt text 117 00:06:32,590 --> 00:06:37,590 and then we need to specify the width and the height. 118 00:06:40,170 --> 00:06:41,960 Now let's start with alt. 119 00:06:41,960 --> 00:06:44,713 The alt text could just be our title here, 120 00:06:44,713 --> 00:06:47,113 so I'll just use title. 121 00:06:48,190 --> 00:06:51,010 Now for width and height 122 00:06:51,010 --> 00:06:53,550 I also prepared some values which should work 123 00:06:53,550 --> 00:06:58,550 and that's 300 and 200 pixels roughly. 124 00:06:59,490 --> 00:07:01,930 That should produce good-looking images. 125 00:07:01,930 --> 00:07:04,580 We will also sometimes have images, 126 00:07:04,580 --> 00:07:06,770 which are a bit wider than 300 127 00:07:06,770 --> 00:07:10,380 because here the image will actually scale in size 128 00:07:10,380 --> 00:07:12,840 as defined in css. 129 00:07:12,840 --> 00:07:17,750 The css code is such that the image will differ in size 130 00:07:17,750 --> 00:07:21,230 but still will always produce good-looking images 131 00:07:21,230 --> 00:07:23,210 with these settings. 132 00:07:23,210 --> 00:07:27,530 And it always will be a bit of tweaking and trial and error 133 00:07:27,530 --> 00:07:29,380 to find good settings here 134 00:07:29,380 --> 00:07:32,750 to get images which are as small as possible 135 00:07:32,750 --> 00:07:34,283 and still look good. 136 00:07:35,450 --> 00:07:36,970 But I'll come back to the image later 137 00:07:36,970 --> 00:07:38,840 because we will also need to add 138 00:07:38,840 --> 00:07:41,450 the layout property here later. 139 00:07:41,450 --> 00:07:43,110 But for the moment let's keep it like this 140 00:07:43,110 --> 00:07:47,040 so that we then also see why we will need to add it. 141 00:07:47,040 --> 00:07:49,160 For the moment let's focus on the source instead. 142 00:07:49,160 --> 00:07:50,910 What is the source? 143 00:07:50,910 --> 00:07:52,610 Well, we get an image here 144 00:07:52,610 --> 00:07:54,270 but the image which we get 145 00:07:54,270 --> 00:07:58,050 will actually just be the image file name. 146 00:07:58,050 --> 00:08:01,483 So we need to construct a full imagePath first 147 00:08:01,483 --> 00:08:03,913 because the file name is not enough. 148 00:08:04,820 --> 00:08:06,890 And I'll do this with a template literal. 149 00:08:06,890 --> 00:08:10,730 So with back ticks and we will start with a hard-coded 150 00:08:10,730 --> 00:08:14,330 string of /images/posts. 151 00:08:14,330 --> 00:08:16,310 Now that's important at the moment 152 00:08:16,310 --> 00:08:20,410 in the public images folder, we have no posts folder. 153 00:08:20,410 --> 00:08:22,513 I'll change this now and I'll add one. 154 00:08:23,500 --> 00:08:25,260 This folder is empty right now 155 00:08:25,260 --> 00:08:28,270 but it will very soon contain some images. 156 00:08:28,270 --> 00:08:30,680 So it's this folder which will hold images 157 00:08:30,680 --> 00:08:32,563 for individual posts. 158 00:08:33,780 --> 00:08:37,210 And that's therefore the start of this image path. 159 00:08:37,210 --> 00:08:41,520 Then I wanna have a sub folder in that post folder 160 00:08:41,520 --> 00:08:43,610 for every post which we add. 161 00:08:43,610 --> 00:08:47,500 And that sub folder should have the unique identifier 162 00:08:47,500 --> 00:08:49,080 of that post as a name. 163 00:08:49,080 --> 00:08:53,560 So that slug, hence the next segment here is the slug. 164 00:08:53,560 --> 00:08:57,160 We'll dive into a sub folder of that slug 165 00:08:57,160 --> 00:09:01,830 So with that slug as a name in that images posts folder 166 00:09:01,830 --> 00:09:02,940 and then in there, 167 00:09:02,940 --> 00:09:06,630 we look for the actual image file like this. 168 00:09:06,630 --> 00:09:09,220 That's my image path and therefore now 169 00:09:09,220 --> 00:09:11,613 that is what I'll set here as a source. 170 00:09:13,380 --> 00:09:17,840 Okay, so that is now this PostItem component here 171 00:09:18,800 --> 00:09:21,230 for image to work we however 172 00:09:21,230 --> 00:09:26,230 still need to import this image component from next image. 173 00:09:27,360 --> 00:09:28,980 But now we've got this setup. 174 00:09:28,980 --> 00:09:33,610 Now we can connect this to our posts-grid 175 00:09:33,610 --> 00:09:36,860 and then start adding some dummy data 176 00:09:36,860 --> 00:09:38,903 so that we do see some output. 13901

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.