Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:02,050 --> 00:00:04,580
So it's time to convert that Markdown,
2
00:00:04,580 --> 00:00:07,460
and for that we'll install a third party package.
3
00:00:07,460 --> 00:00:09,840
So I'll quit my development server,
4
00:00:09,840 --> 00:00:14,110
and npm install a new package which will help us with that.
5
00:00:14,110 --> 00:00:18,710
And that package is the react-markdown package.
6
00:00:18,710 --> 00:00:23,457
This package takes Markdown and outputs it as JSX.
7
00:00:24,430 --> 00:00:26,593
So we need to install that package.
8
00:00:28,040 --> 00:00:32,910
And once that's done, we can restart the development server,
9
00:00:32,910 --> 00:00:36,830
and in the post-content JS file,
10
00:00:36,830 --> 00:00:41,830
import ReactMarkdown, with a capital R at the beginning
11
00:00:41,890 --> 00:00:46,890
because this will act as a component from react-markdown.
12
00:00:47,950 --> 00:00:50,840
So we import the ReactMarkdown component
13
00:00:50,840 --> 00:00:55,030
from that react-markdown package we just installed.
14
00:00:55,030 --> 00:00:57,733
Now, if we go down here, what we can do
15
00:00:57,733 --> 00:01:01,330
is instead of outputting our content like this,
16
00:01:01,330 --> 00:01:05,203
we output ReactMarkdown, this component here,
17
00:01:06,060 --> 00:01:09,100
and between the Opening and Closing Tags,
18
00:01:09,100 --> 00:01:12,370
we pass our content just like this.
19
00:01:12,370 --> 00:01:15,660
If we do that, you'll notice something interesting.
20
00:01:15,660 --> 00:01:19,260
If we reload, this now changed its style.
21
00:01:19,260 --> 00:01:22,270
The hash is gone, and if we inspect this
22
00:01:22,270 --> 00:01:24,300
it's rendered as an h1 tag.
23
00:01:24,300 --> 00:01:28,210
So it was translated to a title.
24
00:01:28,210 --> 00:01:32,510
So this Markdown to JSX translation works
25
00:01:32,510 --> 00:01:35,290
simply by adding this component,
26
00:01:35,290 --> 00:01:39,163
which is of course awesome and really makes our life easier.
27
00:01:40,000 --> 00:01:42,960
Now we're going to come back to this component later,
28
00:01:42,960 --> 00:01:46,590
when it comes to rendering Inline Images.
29
00:01:46,590 --> 00:01:49,320
So Images as part of our posts,
30
00:01:49,320 --> 00:01:52,130
and when it comes to rendering Code Snippets
31
00:01:52,130 --> 00:01:54,750
because there we'll then tweak it a little bit,
32
00:01:54,750 --> 00:01:57,313
but for the moment it just works.
33
00:01:58,190 --> 00:02:02,050
And therefore, as a next step, before we tweak this anymore
34
00:02:02,050 --> 00:02:04,120
and before we dive deeper into that,
35
00:02:04,120 --> 00:02:07,900
let's now replace all that dummy content
36
00:02:07,900 --> 00:02:10,340
with some actual content
37
00:02:10,340 --> 00:02:12,640
because we got all the building blocks, now.
38
00:02:12,640 --> 00:02:14,010
We got the core pages.
39
00:02:14,010 --> 00:02:17,810
We understand that we plan to use Markdown,
40
00:02:17,810 --> 00:02:21,480
and therefore we're now ready to take the next step.
41
00:02:21,480 --> 00:02:23,620
Add a real data source,
42
00:02:23,620 --> 00:02:26,050
then load data from that source,
43
00:02:26,050 --> 00:02:28,123
and then render that data.
3457
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.