Skip to content

Commit a9e1ea4

Browse files
authored
Update README.md
1 parent faf8ae4 commit a9e1ea4

1 file changed

Lines changed: 22 additions & 11 deletions

File tree

README.md

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@ The Devbook Docusaurus code video plugin allows you to [add a video to a code bl
44
## Supported video sources
55
- YouTube
66

7-
## Usage
8-
Install plugin:
7+
## Installation
8+
9+
Install the package:
910
```sh
1011
npm install @devbookhq/docusaurus-code-video-plugin
1112
```
13+
or
14+
```sh
15+
yarn add @devbookhq/docusaurus-code-video-plugin
16+
```
1217

1318
Add plugin to `docusaurus.config.js`:
1419
```js
@@ -17,8 +22,8 @@ module.exports = {
1722
}
1823
```
1924

20-
### Add video to a code snippet
21-
In **Markdown** add `youtubeID` attribute to the code block:
25+
## Usage with markdown (`.md`)
26+
Add `youtubeID` attribute to a code block:
2227

2328
```js youtubeID=4HGNqFdaD34
2429
function main() {
@@ -27,7 +32,10 @@ In **Markdown** add `youtubeID` attribute to the code block:
2732
}
2833
```
2934

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:
3139

3240
```jsx
3341
import CodeBlock from '@theme/CodeBlock';
@@ -41,13 +49,12 @@ import MyComponentSource from '!!raw-loader!./myComponent';
4149
</CodeBlock>
4250
```
4351

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
4553

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]`.
4955

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.
5158

5259
Add the highlight attributes to the code block in **Markdown**:
5360

@@ -60,6 +67,11 @@ Add the highlight attributes to the code block in **Markdown**:
6067

6168
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`.
6269

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

6577
```jsx
@@ -76,5 +88,4 @@ import MyComponentSource from '!!raw-loader!./myComponent';
7688
```
7789

7890
## Styling
79-
### Style highlighted code lines
8091
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)