Skip to content

Commit e23eaec

Browse files
committed
Improve readme
1 parent fa54dc0 commit e23eaec

1 file changed

Lines changed: 17 additions & 12 deletions

File tree

README.md

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Devbook Docusaurus Video Plugin
2-
The Devbook Docusaurus Video Plugin allows you to [attach a video to a code block](#add-video-to-a-code-snippet) in your docs and [highlight code lines](#add-code-highlights-at-video-timestamps) as the video plays.
2+
The Devbook Docusaurus Video Plugin allows you to [add a video to a code block](#add-video-to-a-code-snippet) in your docs and [highlight code lines](#highlight-code-lines-as-the-video-plays) as the video plays.
3+
4+
## Supported video sources
5+
- YouTube
36

47
## Usage
58
Install plugin:
@@ -20,6 +23,7 @@ In **Markdown** add `youtubeID` attribute to the code block:
2023
```js youtubeID=4HGNqFdaD34
2124
function main() {
2225

26+
2327
}
2428
```
2529

@@ -32,32 +36,33 @@ import MyComponentSource from '!!raw-loader!./myComponent';
3236
<CodeBlock youtubeID="4HGNqFdaD34" language="jsx">{MyComponentSource}</CodeBlock>
3337
```
3438

35-
> You need to pass just the YouTube video ID, not the whole URL. You can get the `youtubeID` from the normal video URL - `https://www.youtube.com/watch?v=[youtubeID]`, or from the embed URL - `https://www.youtube.com/embed/[youtubeID]`.
39+
> 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]`.
3640
37-
### Add code highlights at video timestamps
38-
The video highlights are in the format `start-end=(range)`.
39-
The start and the end timestamps are in the `H:M:S` format and the hours are optional (`M:S`).
41+
### Highlight code lines as the video plays
42+
The code line highlights are in the format `videoStartTime-videoEndTime=(codeLinesRange)`.
43+
The start and the end timestamps are in the `H:M:S` format. Hours are optional (`M:S`).
4044

41-
In **Markdown** add highlight attributes to the code block:
45+
Add the highlight attributes to the code block in **Markdown**:
4246

43-
```js youtubeID=4HGNqFdaD34 0:10-1:00=(1) 1:10-1:20=(1,2-3)
47+
```js youtubeID=4HGNqFdaD34 0:10-1:00=(1) 1:10-1:20=(1,2-4)
4448
function main() {
4549

50+
4651
}
4752
```
4853

54+
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`.
55+
4956
If you are using **MDX/JSX/TSX** [`CodeBlock`](https://docusaurus.io/docs/markdown-features/code-blocks) add the highlight attributes as props:
5057

5158
```jsx
5259
import CodeBlock from '@theme/CodeBlock';
5360
import MyComponentSource from '!!raw-loader!./myComponent';
5461

55-
<CodeBlock youtubeID="4HGNqFdaD34" "0:10-1:00"="(1)" "1:10-1:20"="(1,2-3)" language="jsx">{MyComponentSource}</CodeBlock>
62+
<CodeBlock youtubeID="4HGNqFdaD34" "0:10-1:00"="(1)" "1:10-1:20"="(1,2-4)" language="jsx">{MyComponentSource}</CodeBlock>
5663
```
5764

5865
> 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.
5966
60-
> You can change the video line 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).
61-
62-
## Supported video sources
63-
- YouTube
67+
#### Highlight styling
68+
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

Comments
 (0)