Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:02,220 --> 00:00:04,500
Now the underscore app JS file
2
00:00:04,500 --> 00:00:07,810
is not the only special next JS file,
3
00:00:07,810 --> 00:00:11,880
which allows us to set application wide settings.
4
00:00:11,880 --> 00:00:15,700
There also is the underscore document.JS file,
5
00:00:15,700 --> 00:00:20,233
which we can add just like _app def _document JS
6
00:00:22,760 --> 00:00:25,780
has to be added in the pages folder
7
00:00:25,780 --> 00:00:29,070
directly in the pages folder, not in some sub folder,
8
00:00:29,070 --> 00:00:32,170
but in the root level of the pages folder.
9
00:00:32,170 --> 00:00:33,570
It's not there by default,
10
00:00:33,570 --> 00:00:37,310
but if you add it next JS will take it into account
11
00:00:37,310 --> 00:00:38,550
and we'll use it.
12
00:00:38,550 --> 00:00:41,140
But what does documentary JS do.
13
00:00:41,140 --> 00:00:44,930
App JS is your application shell.
14
00:00:44,930 --> 00:00:48,070
You can imagine app JS as the root component
15
00:00:48,070 --> 00:00:53,030
inside of the body section of your HTML document.
16
00:00:53,030 --> 00:00:55,530
Document JS allows you to customize
17
00:00:55,530 --> 00:00:58,460
the entire HTML document.
18
00:00:58,460 --> 00:01:02,595
So all the elements that make up an HTML document,
19
00:01:02,595 --> 00:01:04,300
if you need to do that,
20
00:01:04,300 --> 00:01:07,260
you can add to the _documented JS file.
21
00:01:07,260 --> 00:01:10,263
And then you need to add a special component in there,
22
00:01:11,160 --> 00:01:14,530
a class-based component, as it turns out,
23
00:01:14,530 --> 00:01:17,070
which you could name my document,
24
00:01:17,070 --> 00:01:19,160
and it has to be a class-based component
25
00:01:19,160 --> 00:01:22,460
because it must extend some component offered
26
00:01:22,460 --> 00:01:25,050
and provided by next JS
27
00:01:25,050 --> 00:01:29,100
for this we need to add an import a import of document
28
00:01:29,100 --> 00:01:31,973
from next slash document.
29
00:01:32,810 --> 00:01:35,920
So we need to extend document here
30
00:01:35,920 --> 00:01:38,890
and therefore we need to use a class based component.
31
00:01:38,890 --> 00:01:41,860
And then in this class based component,
32
00:01:41,860 --> 00:01:44,770
we need to add a render method like we do
33
00:01:44,770 --> 00:01:47,340
in class based react components.
34
00:01:47,340 --> 00:01:50,123
And then here we return some JSX code.
35
00:01:51,030 --> 00:01:54,080
That also should be special JSX code
36
00:01:54,080 --> 00:01:56,513
with a very specific structure.
37
00:01:57,450 --> 00:01:59,840
For this we need to import more components
38
00:01:59,840 --> 00:02:02,070
from next document.
39
00:02:02,070 --> 00:02:06,070
And those components are the HTML component,
40
00:02:06,070 --> 00:02:10,130
the head component, the main component,
41
00:02:10,130 --> 00:02:12,883
and the next script component.
42
00:02:13,890 --> 00:02:16,590
Very important the head component,
43
00:02:16,590 --> 00:02:18,150
which we are importing here
44
00:02:18,150 --> 00:02:22,880
is not the same head component as we import from next head.
45
00:02:22,880 --> 00:02:25,480
These are different components.
46
00:02:25,480 --> 00:02:29,480
Head from next head is important to use it anywhere
47
00:02:29,480 --> 00:02:32,928
in your JSX code to adjust the head content
48
00:02:32,928 --> 00:02:35,120
of the rendered page,
49
00:02:35,120 --> 00:02:37,640
head imported from next document
50
00:02:37,640 --> 00:02:41,070
should only be used in this special document component,
51
00:02:41,070 --> 00:02:42,563
which we are building here.
52
00:02:43,730 --> 00:02:46,090
Now with those components imported
53
00:02:46,090 --> 00:02:49,520
in the rendered JSX content here,
54
00:02:49,520 --> 00:02:53,380
we should return a JSX structure
55
00:02:53,380 --> 00:02:57,980
where we have the HTML element as a rapper.
56
00:02:57,980 --> 00:03:00,650
Then we have the head element like this,
57
00:03:00,650 --> 00:03:04,730
and then we have a body HTML element,
58
00:03:04,730 --> 00:03:07,110
so no special component,
59
00:03:07,110 --> 00:03:11,780
but the standard body element and inside of that main,
60
00:03:11,780 --> 00:03:14,893
and next script like this,
61
00:03:15,850 --> 00:03:18,400
that is the default structure, which you should add.
62
00:03:18,400 --> 00:03:20,150
And that's the default structure,
63
00:03:20,150 --> 00:03:24,420
which the default document has if you don't override it.
64
00:03:24,420 --> 00:03:26,010
So if you override it,
65
00:03:26,010 --> 00:03:28,610
you wanna recreate that structure
66
00:03:28,610 --> 00:03:31,940
and you should also of course export the document
67
00:03:31,940 --> 00:03:33,990
as the default.
68
00:03:33,990 --> 00:03:36,400
Now what could be reasons for overriding
69
00:03:36,400 --> 00:03:38,300
that default document?
70
00:03:38,300 --> 00:03:42,590
Well if you want to configure that general document,
71
00:03:42,590 --> 00:03:46,340
for example if you wanna add the Lang attribute
72
00:03:46,340 --> 00:03:51,340
on HTML and set this to en if we don't do this
73
00:03:52,000 --> 00:03:55,130
and save everything and we reload,
74
00:03:55,130 --> 00:03:57,400
we see that there is no Lang attribute
75
00:03:57,400 --> 00:03:59,863
on the rendered HTML element.
76
00:04:01,090 --> 00:04:04,610
If we do that, if we add Lang and set this to en
77
00:04:04,610 --> 00:04:08,210
or to whichever language applies to your page,
78
00:04:08,210 --> 00:04:11,210
then if we restart the Dev Server,
79
00:04:11,210 --> 00:04:13,180
which we need to do here once,
80
00:04:13,180 --> 00:04:17,100
if we reload the page there after we see the Lang attribute,
81
00:04:17,100 --> 00:04:19,290
so I needed to restart the server here
82
00:04:19,290 --> 00:04:20,660
for this to have an effect,
83
00:04:20,660 --> 00:04:23,533
but then we see that this is taken into account.
84
00:04:24,750 --> 00:04:27,980
We could also add other elements here to the body,
85
00:04:27,980 --> 00:04:32,487
like for example a div with an idea of overlays like that.
86
00:04:34,060 --> 00:04:35,933
If we do that and save this,
87
00:04:37,630 --> 00:04:41,060
and we reload we see in the body there is this div
88
00:04:41,060 --> 00:04:42,900
why might we wanna do that?
89
00:04:42,900 --> 00:04:47,120
Well this allows us to add HTML content outside
90
00:04:47,120 --> 00:04:50,040
of our application component tree.
91
00:04:50,040 --> 00:04:52,520
For example for using those elements
92
00:04:52,520 --> 00:04:54,400
with react portals then
93
00:04:54,400 --> 00:04:57,130
we could select this div with a react portal
94
00:04:57,130 --> 00:05:01,610
to portal our modals or overlays to this element.
95
00:05:01,610 --> 00:05:04,420
So having extra HTML elements,
96
00:05:04,420 --> 00:05:07,730
which are outside of our application components tree
97
00:05:07,730 --> 00:05:09,810
can sometimes be useful
98
00:05:09,810 --> 00:05:12,350
because you are next to JS application
99
00:05:12,350 --> 00:05:14,800
is in the end rendered by this main component,
100
00:05:14,800 --> 00:05:16,490
which would therefore must include,
101
00:05:16,490 --> 00:05:20,730
but adding extra elements can sometimes also be beneficial
102
00:05:20,730 --> 00:05:25,380
and therefore If you need to edit the overall HTML document,
103
00:05:25,380 --> 00:05:29,173
you can do this by adding such _document JS file.
8008
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.