-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbilibili.js
19 lines (18 loc) · 984 Bytes
/
bilibili.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
function plugin(hook, vm) {
hook.beforeEach(function(content) {
var match = content.match(/- Bilibili video((?:\n- .*)+)/);
if (match) {
var lines = match[1].split('\n');
lines.shift(); // delete first elem
var videos = lines.map(function(line) {
line = '<div style="width: 600px; height: 400px;flex-grow: 0;min-width: 100px;margin: 10px;"><iframe src="//player.bilibili.com/player.html?' + line.slice(2).trim() +
'&autoplay=0" style="width: 100%; height: 100%;" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true"></iframe></div>';
return line;
});
new_content = '<div style="display: flex;flex-wrap: wrap; justify-content: flex-start; align-items: stretch; ">' + videos.join("") + '</div>';
content = content.replace(match[0], new_content);
}
return content;
});
}
window.$docsify.plugins = [].concat(plugin, window.$docsify.plugins);