You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In **Markdown** add `youtubeID` attribute to the code block:
25
+
##Usage with markdown (`.md`)
26
+
Add `youtubeID` attribute to a code block:
22
27
23
28
```js youtubeID=4HGNqFdaD34
24
29
function main() {
@@ -27,7 +32,10 @@ In **Markdown** add `youtubeID` attribute to the code block:
27
32
}
28
33
```
29
34
30
-
If you are using **MDX/JSX/TSX**[`CodeBlock`](https://docusaurus.io/docs/markdown-features/code-blocks) add the `youtubeID` prop:
35
+
36
+
## Usage with [`CodeBlock`](https://docusaurus.io/docs/markdown-features/code-blocks) (`.mdx`, `.tsx`, `.jsx`)
37
+
38
+
Add the `youtubeID` prop to the component:
31
39
32
40
```jsx
33
41
importCodeBlockfrom'@theme/CodeBlock';
@@ -41,13 +49,12 @@ import MyComponentSource from '!!raw-loader!./myComponent';
41
49
</CodeBlock>
42
50
```
43
51
44
-
> You need to pass just the YouTube video ID, not the whole URL. You can get the `youtubeID` from the regular Youtube video URL - `https://www.youtube.com/watch?v=[youtubeID]`, or from the embed URL - `https://www.youtube.com/embed/[youtubeID]`.
52
+
## Youtube video ID
45
53
46
-
### Highlight code lines as the video plays
47
-
The code line highlights are in the format `videoStartTime-videoEndTime=(codeLinesRange)`.
48
-
The start and the end timestamps are in the `H:M:S` format. Hours are optional (`M:S`).
54
+
Pass the YouTube video ID, not the full URL. The `youtubeID` is part of the regular Youtube video URL - `https://www.youtube.com/watch?v=[youtubeID]`, or the embed video URL - `https://www.youtube.com/embed/[youtubeID]`.
49
55
50
-
> The highlight range format is the same as in the [Docusaurus code blocks](https://docusaurus.io/docs/markdown-features/code-blocks#highlighting-with-metadata-string), just with the `()` parentheses instead of the `{}` parentheses.
56
+
## How to highlighting code lines as the video plays
57
+
The plugin allows you to highlight different code lines (and ranges of code lines) as the video plays.
51
58
52
59
Add the highlight attributes to the code block in **Markdown**:
53
60
@@ -60,6 +67,11 @@ Add the highlight attributes to the code block in **Markdown**:
60
67
61
68
The example above will highlight a code line number `1` from the time `0:10` until `1:00`. Then highlights code lines `1`, `2`, `3`, and `4` from the time `1:10` to the time `1:20`.
62
69
70
+
The code line highlights are in the format `videoStartTime-videoEndTime=(codeLinesRange)`.
71
+
The start and the end timestamps are in the `H:M:S` format. Hours are optional (`M:S`).
72
+
73
+
> The highlight range format is the same as in the [Docusaurus code blocks](https://docusaurus.io/docs/markdown-features/code-blocks#highlighting-with-metadata-string), just with the `()` parentheses instead of the `{}` parentheses.
74
+
63
75
If you are using **MDX/JSX/TSX**[`CodeBlock`](https://docusaurus.io/docs/markdown-features/code-blocks) add the highlight attributes as props:
64
76
65
77
```jsx
@@ -76,5 +88,4 @@ import MyComponentSource from '!!raw-loader!./myComponent';
76
88
```
77
89
78
90
## Styling
79
-
### Style highlighted code lines
80
91
You can change the code lines' highlight style by customizing the `docusaurus-highlight-code-line` class - the same way you would change the [default Docusaurus highlight style](https://docusaurus.io/docs/markdown-features/code-blocks#line-highlighting).
0 commit comments