-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
24 lines (24 loc) · 957 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
module.exports = {
blocks: {
/**
* This is run when HonKit parses the book.
*
* Link to a YouTube video. Require the following parameters:
*
* @param id The ID of the YouTube video. For example, if the URL of the video is
*
* https://www.youtube.com/watch?v=p3G5IXn0K7A
*
* then the ID of the video is p3G5IXn0K7A.
* @param title The title of the video.
*/
youtube: {
process: (block) => {
const { id, title } = block.kwargs;
const header = `<a href="http://www.youtube.com/watch?v=${id}" target="_blank">${title}</a>`;
const image = `<a href="http://www.youtube.com/watch?v=${id}" title="${title}" target="_blank"><img src="http://img.youtube.com/vi/${id}/0.jpg" alt="${title}"></a>`;
return `${header}<br/>${image}`;
}
}
}
};