All language subtitles for 005 Adding Layout & Navigation_Downloadly.ir_en

af Afrikaans
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
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
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian Download
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
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,360 So we got our hero component here. 2 00:00:04,360 --> 00:00:06,270 It's looking good, hopefully, 3 00:00:06,270 --> 00:00:11,080 and now we also need featured posts for this starting page. 4 00:00:11,080 --> 00:00:14,290 Now, what we'll also need besides featured posts, though, 5 00:00:14,290 --> 00:00:17,110 is a navigation bar at the top 6 00:00:17,110 --> 00:00:20,880 because at the moment we only have one working page 7 00:00:20,880 --> 00:00:23,860 with not too much content on it, arguably, 8 00:00:23,860 --> 00:00:26,850 but later we will have other pages as well, 9 00:00:26,850 --> 00:00:30,200 the All Posts page and the Contact page. 10 00:00:30,200 --> 00:00:32,450 So therefore to be able to reach that, 11 00:00:32,450 --> 00:00:34,570 we wanna add some navigation, 12 00:00:34,570 --> 00:00:36,930 and hence that is something I'll do first 13 00:00:36,930 --> 00:00:39,850 before we then come back to the featured posts. 14 00:00:39,850 --> 00:00:43,860 I wanna add a navigation bar, or to be precise, 15 00:00:43,860 --> 00:00:48,490 I wanna add a general layout because the navigation bar, 16 00:00:48,490 --> 00:00:50,520 which should be shown at the top, 17 00:00:50,520 --> 00:00:53,480 will not only be needed on the homepage. 18 00:00:53,480 --> 00:00:56,220 Instead, we will need it on all pages, 19 00:00:56,220 --> 00:00:58,810 and that can be solved with a layout, 20 00:00:58,810 --> 00:01:00,810 as you'll learn throughout the course. 21 00:01:00,810 --> 00:01:04,459 We can utilize this _app JS file here 22 00:01:04,459 --> 00:01:09,340 to wrap the component which is rendered there 23 00:01:09,340 --> 00:01:11,920 which is actually just the page content 24 00:01:11,920 --> 00:01:15,120 that was loaded for the different URLs 25 00:01:15,120 --> 00:01:17,540 with a general layout. 26 00:01:17,540 --> 00:01:18,930 That is what we can do, 27 00:01:18,930 --> 00:01:23,160 and what we typically wanna do in Next.js applications, 28 00:01:23,160 --> 00:01:26,460 and therefore let's build such a layout component. 29 00:01:26,460 --> 00:01:28,420 For that, in the components folder, 30 00:01:28,420 --> 00:01:31,800 we can create a new subfolder called layout, 31 00:01:31,800 --> 00:01:34,010 and in there, I wanna add a couple 32 00:01:34,010 --> 00:01:38,350 of components that help us create layouts. 33 00:01:38,350 --> 00:01:41,210 The first one will be the layout component itself, 34 00:01:41,210 --> 00:01:46,210 a layout JS file, but then I'll add two other files as well, 35 00:01:46,790 --> 00:01:48,610 since I wanna split my layout 36 00:01:48,610 --> 00:01:51,000 into multiple sub-components. 37 00:01:51,000 --> 00:01:53,820 For example, I want it to have a separate component 38 00:01:53,820 --> 00:01:56,960 that holds the actual navigation bar, 39 00:01:56,960 --> 00:01:59,840 so I'll name this main-navigation. 40 00:01:59,840 --> 00:02:02,023 This will be my navigation component, 41 00:02:02,880 --> 00:02:06,270 and that navigation component should also render 42 00:02:06,270 --> 00:02:08,680 some logo for my blog, 43 00:02:08,680 --> 00:02:12,220 and therefore I'll create a separate logo component, 44 00:02:12,220 --> 00:02:15,140 and of course you can split, and mix, and match, 45 00:02:15,140 --> 00:02:18,400 and compose your components just as you need to. 46 00:02:18,400 --> 00:02:20,420 This is just some example split 47 00:02:20,420 --> 00:02:22,920 which I came up with which works for me. 48 00:02:22,920 --> 00:02:24,370 If it doesn't work for you, 49 00:02:24,370 --> 00:02:27,380 if you wanna split it in a more granular way 50 00:02:27,380 --> 00:02:29,630 or have bigger components, 51 00:02:29,630 --> 00:02:33,360 so less splits, that's of course also fine. 52 00:02:33,360 --> 00:02:35,663 You just need to adjust the styles then. 53 00:02:36,650 --> 00:02:39,500 Now with that, let's start with the layout component. 54 00:02:39,500 --> 00:02:43,130 In there, we can, again, create a function 55 00:02:43,130 --> 00:02:46,173 and export that function, Layout, 56 00:02:48,380 --> 00:02:52,300 and in that function, we then return a fragment 57 00:02:53,290 --> 00:02:57,080 because I wanna have two adjacent JSX elements, 58 00:02:57,080 --> 00:03:00,850 and the first one will be the MainNavigation, 59 00:03:00,850 --> 00:03:02,830 so this separate component 60 00:03:02,830 --> 00:03:06,240 which we'll store in the main-navigation file. 61 00:03:06,240 --> 00:03:11,240 The second JSX element will be the regular main HTML element 62 00:03:11,340 --> 00:03:14,580 in which I wanna output properties, 63 00:03:14,580 --> 00:03:17,100 whoops, props.children, 64 00:03:17,100 --> 00:03:18,970 and for this, of course, we need to make sure 65 00:03:18,970 --> 00:03:21,483 that we accept props here, 66 00:03:23,360 --> 00:03:25,890 props.children, because we will wrap 67 00:03:25,890 --> 00:03:30,050 this Layout component around this component here 68 00:03:30,050 --> 00:03:32,810 in the _app JS file. 69 00:03:32,810 --> 00:03:34,990 We can actually already do that here. 70 00:03:34,990 --> 00:03:39,970 In this file, we can already import Layout from, 71 00:03:42,010 --> 00:03:44,180 and then go up one level, 72 00:03:44,180 --> 00:03:46,280 dive into the components folder, 73 00:03:46,280 --> 00:03:49,520 into the layout folder and the layout file, 74 00:03:49,520 --> 00:03:53,350 and then just wrap component with Layout, 75 00:03:53,350 --> 00:03:57,793 so create Layout here and wrap it around this component. 76 00:03:58,740 --> 00:04:03,250 Now it's this component which will be used as children, 77 00:04:03,250 --> 00:04:07,083 or as a child, inside of the Layout component, so here. 78 00:04:08,320 --> 00:04:10,060 So that's step number one. 79 00:04:10,060 --> 00:04:11,860 Now I'm using the main navigation here, 80 00:04:11,860 --> 00:04:15,292 and hence I also already wanna import MainNavigation 81 00:04:15,292 --> 00:04:19,810 from that main-navigation JavaScript file. 82 00:04:19,810 --> 00:04:23,370 That file, however, is completely empty right now, 83 00:04:23,370 --> 00:04:25,550 and that needs to change therefore. 84 00:04:25,550 --> 00:04:29,500 So if we go to the main-navigation file here, 85 00:04:29,500 --> 00:04:30,480 we, of course, again, 86 00:04:30,480 --> 00:04:33,900 wanna create a MainNavigation function, 87 00:04:33,900 --> 00:04:37,950 and then export that as a default, 88 00:04:37,950 --> 00:04:39,163 as we always do it. 89 00:04:40,130 --> 00:04:43,250 And now inside that MainNavigation component, 90 00:04:43,250 --> 00:04:46,380 I wanna return a header element, 91 00:04:46,380 --> 00:04:50,670 and then there as a first element, my logo, 92 00:04:50,670 --> 00:04:54,330 and side by side to that, a nav bar 93 00:04:54,330 --> 00:04:57,380 with a list of nav items. 94 00:04:57,380 --> 00:05:01,090 So here I'll add a unordered list with my list items 95 00:05:01,090 --> 00:05:04,950 where in the list items, I have my links. 96 00:05:04,950 --> 00:05:09,390 Now, for the links we will not use the standard anchor tag 97 00:05:09,390 --> 00:05:12,520 because that would be handled by the browser only, 98 00:05:12,520 --> 00:05:16,020 and when we click it, we would load a brand-new page 99 00:05:16,020 --> 00:05:18,330 and send a brand-new request. 100 00:05:18,330 --> 00:05:21,640 Instead, we want to use Next's Link component 101 00:05:21,640 --> 00:05:25,660 to take advantage of automatic data prefetching 102 00:05:25,660 --> 00:05:27,050 which it does for us, 103 00:05:27,050 --> 00:05:29,230 and to take advantage of the fact 104 00:05:29,230 --> 00:05:32,480 that we stay in a single-page application 105 00:05:32,480 --> 00:05:34,733 once the page was loaded initially. 106 00:05:35,720 --> 00:05:39,793 So therefore we wanna import Link from next/link, 107 00:05:40,770 --> 00:05:44,390 like this, like we did it many times before in this course, 108 00:05:44,390 --> 00:05:48,260 and to then just output Link here, 109 00:05:48,260 --> 00:05:50,150 so create a link here. 110 00:05:50,150 --> 00:05:52,440 Now the link needs a ref attribute 111 00:05:52,440 --> 00:05:55,250 where we point at /posts, for example, 112 00:05:55,250 --> 00:05:58,213 and load the Posts page, 113 00:06:00,200 --> 00:06:04,660 and it has to be /posts because of our page structure. 114 00:06:04,660 --> 00:06:08,050 We have the posts folder with the index JS file 115 00:06:08,050 --> 00:06:11,380 which should be loaded when we wanna load all posts, 116 00:06:11,380 --> 00:06:15,090 and you learned before in this course that this structure 117 00:06:15,090 --> 00:06:18,860 in the pages folder leads to a /posts route 118 00:06:18,860 --> 00:06:21,310 which is inferred by Next.js, 119 00:06:21,310 --> 00:06:23,513 so we wanna link to that route here. 120 00:06:24,980 --> 00:06:26,670 Now, that's not the only link though. 121 00:06:26,670 --> 00:06:31,070 I also wanna have a link to my Contact page 122 00:06:31,070 --> 00:06:34,193 because we also have this contact JS file, 123 00:06:35,240 --> 00:06:37,690 and that file will be translated 124 00:06:37,690 --> 00:06:40,340 to a /contact route, as you learned, 125 00:06:40,340 --> 00:06:43,513 so we also wanna have a /contact route here. 126 00:06:44,700 --> 00:06:45,990 So now we've got that. 127 00:06:45,990 --> 00:06:49,670 I actually also wanna make the logo clickable 128 00:06:49,670 --> 00:06:51,810 so that when we click the logo 129 00:06:51,810 --> 00:06:54,280 we're taken back to the starting page. 130 00:06:54,280 --> 00:06:57,350 That's a quite common pattern on websites, 131 00:06:57,350 --> 00:07:02,350 and therefore we also wrap the logo with a link, like this, 132 00:07:02,380 --> 00:07:06,540 and give this a ref of just slash 133 00:07:06,540 --> 00:07:08,910 to go back to the starting page. 134 00:07:08,910 --> 00:07:10,750 Now you might remember 135 00:07:10,750 --> 00:07:15,120 that there was this special behavior of Link 136 00:07:15,120 --> 00:07:20,120 when the child you passed to it was not plain text. 137 00:07:20,540 --> 00:07:22,760 If you pass your own component, 138 00:07:22,760 --> 00:07:26,490 or any other HTML content to a link, 139 00:07:26,490 --> 00:07:30,900 Link will not render an anchor tag by default. 140 00:07:30,900 --> 00:07:35,200 It only does that if you just pass plain text to it. 141 00:07:35,200 --> 00:07:37,750 If you pass anything else than plain text, 142 00:07:37,750 --> 00:07:40,880 the link will not render an anchor tag for you, 143 00:07:40,880 --> 00:07:42,210 so in order to get that, 144 00:07:42,210 --> 00:07:46,130 you should then bring your own anchor tag, like this. 145 00:07:46,130 --> 00:07:49,230 You don't need to add ref on that anchor tag. 146 00:07:49,230 --> 00:07:50,930 Link will do that for you. 147 00:07:50,930 --> 00:07:53,260 It will pass the ref set on Link 148 00:07:53,260 --> 00:07:57,500 to the direct child of Link, which is an anchor tag now. 149 00:07:57,500 --> 00:07:59,260 So it will do that for you, 150 00:07:59,260 --> 00:08:02,230 but you have to add the anchor tag element 151 00:08:02,230 --> 00:08:05,453 to tell Link that it should render an anchor tag. 152 00:08:06,290 --> 00:08:11,080 This is not a bug or some inconsistency, but this exists. 153 00:08:11,080 --> 00:08:14,200 This feature exists to make sure 154 00:08:14,200 --> 00:08:17,300 that you can turn any element into a link, 155 00:08:17,300 --> 00:08:20,590 a div, a button, whatever you want, 156 00:08:20,590 --> 00:08:22,770 but here we want an anchor tag still, 157 00:08:22,770 --> 00:08:27,140 so I will add my own anchor tag wrapped around my logo, 158 00:08:27,140 --> 00:08:28,960 and speaking of the logo, 159 00:08:28,960 --> 00:08:31,240 that's, of course, still missing. 160 00:08:31,240 --> 00:08:34,140 I just added this dummy JSX code here, 161 00:08:34,140 --> 00:08:35,760 but we are not importing it, 162 00:08:35,760 --> 00:08:38,809 and the logo JS file is also empty, 163 00:08:38,809 --> 00:08:41,500 and therefore as a next step, we'll work on that, 164 00:08:41,500 --> 00:08:43,823 and we're then also going to add some styling. 13001

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