Skip to content

Commit 5e7132b

Browse files
iBugALeafWolfmmistakes
authoredJul 22, 2020
Enhance Bilibili video support (redo of mmistakes#2522) (mmistakes#2599)
* Enhance support for bilibili videos in responsive video helper, and add corresponding doc * Apply @iBug's review in mmistakes#2522 * Fix danmaku in page hero video * Update video to use case..when for iframe src * Update CHANGELOG and history Co-authored-by: Anran <[email protected]> Co-authored-by: Michael Rose <[email protected]>
1 parent 8164e1f commit 5e7132b

File tree

5 files changed

+50
-16
lines changed

5 files changed

+50
-16
lines changed
 

‎CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- Update link to wtfpl license in README. [#2571](https://github.com/mmistakes/minimal-mistakes/pull/2571)
1111
- Ignore teaser headline in table of contents when including posts list in another page. [#2558](https://github.com/mmistakes/minimal-mistakes/pull/2558)
1212
- Replace Font Awesome Kits with CSS from jsDelivr CDN. [#2583](https://github.com/mmistakes/minimal-mistakes/pull/2583)
13+
- Add `danmaku` option to Bilibili video provider and add corresponding documentation/ [#2599](https://github.com/mmistakes/minimal-mistakes/pull/2599)
1314

1415
## [4.19.3](https://github.com/mmistakes/minimal-mistakes/releases/tag/4.19.3)
1516

‎_includes/page__hero_video.html

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
{% capture video_id %}{{ page.header.video.id }}{% endcapture %}
2-
{% capture video_provider %}{{ page.header.video.provider }}{% endcapture %}
3-
4-
{% include video id=video_id provider=video_provider %}
1+
{% assign video = page.header.video %}
2+
{% include video id=video.id provider=video.provider danmaku=video.danmaku %}

‎_includes/video

+20-11
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
11
{% capture video_id %}{{ include.id }}{% endcapture %}
22
{% capture video_provider %}{{ include.provider }}{% endcapture %}
3+
{% capture video_danmaku %}{{ include.danmaku | default: 0 }}{% endcapture %}
4+
5+
{% capture video_src %}
6+
{% case video_provider %}
7+
{% when "vimeo" %}
8+
https://player.vimeo.com/video/{{ video_id }}?dnt=true
9+
{% when "youtube" %}
10+
https://www.youtube-nocookie.com/embed/{{ video_id }}
11+
{% when "google-drive" %}
12+
https://drive.google.com/file/d/{{ video_id }}/preview
13+
{% when "bilibili" %}
14+
https://player.bilibili.com/player.html?bvid={{ video_id }}&page=1&as_wide=1&high_quality=1&danmaku={{ video_danmaku }}
15+
{% endcase %}
16+
{% endcapture %}
17+
{% assign video_src = video_src | strip %}
318

419
<!-- Courtesy of embedresponsively.com //-->
5-
<div class="responsive-video-container">
6-
{% if video_provider == "vimeo" %}
7-
<iframe src="https://player.vimeo.com/video/{{ video_id }}?dnt=true" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
8-
{% elsif video_provider == "youtube" %}
9-
<iframe src="https://www.youtube-nocookie.com/embed/{{ video_id }}" frameborder="0" allowfullscreen></iframe>
10-
{% elsif video_provider == "google-drive" %}
11-
<iframe src="https://drive.google.com/file/d/{{ video_id }}/preview" frameborder="0" allowfullscreen></iframe>
12-
{% elsif video_provider == "bilibili" %}
13-
<iframe src="https://player.bilibili.com/player.html?bvid={{ video_id }}&page=1&as_wide=1&high_quality=1&danmaku=0" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true"></iframe>
14-
{% endif %}
15-
</div>
20+
{% unless video_src == "" %}
21+
<div class="responsive-video-container">
22+
<iframe src="{{ video_src }}" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowfullscreen></iframe>
23+
</div>
24+
{% endunless %}

‎docs/_docs/14-helpers.md

+25
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ Embed a video from YouTube, Vimeo, Google Drive, or bilibili that responsively s
179179
| ---------- | ------------ | ---------------------------------------------------------- |
180180
| `id` | **Required** | ID of the video |
181181
| `provider` | **Required** | Hosting provider of the video: `youtube`, `vimeo`, `google-drive`, or `bilibili` |
182+
| `danmaku` | Optional | Bilibili only, [details below](#Bilibili) |
182183

183184
### YouTube
184185

@@ -240,6 +241,30 @@ header:
240241
provider: google-drive
241242
```
242243

244+
### Bilibili
245+
246+
To embed the following Bilibili video at url `https://www.bilibili.com/video/BV1E7411e7hC` into a post or page's main content you'd use:
247+
248+
```liquid
249+
{% raw %}{% include video id="BV1E7411e7hC" provider="bilibili" %}{% endraw %}
250+
```
251+
252+
If you want to enable danmaku (弹幕) for the embeded video, which is disabled by default, you can supply an additional parameter `danmaku="1"` as shown below:
253+
254+
```liquid
255+
{% raw %}{% include video id="BV1E7411e7hC" provider="bilibili" danmaku="1" %}{% endraw %}
256+
```
257+
258+
To embed it as a video header you'd use the following YAML Front Matter:
259+
260+
```yaml
261+
header:
262+
video:
263+
id: BV1E7411e7hC
264+
provider: bilibili
265+
danmaku: 1
266+
```
267+
243268
## Table of contents
244269

245270
Auto-generated table of contents list for your posts and pages can be enabled using two methods.

‎docs/_docs/18-history.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ permalink: /docs/history/
55
excerpt: "Change log of enhancements and bug fixes made to the theme."
66
sidebar:
77
nav: docs
8-
last_modified_at: 2020-07-22T15:36:16-04:00
8+
last_modified_at: 2020-07-11T12:31:08+08:00
99
toc: false
1010
---
1111

@@ -21,6 +21,7 @@ toc: false
2121
- Update link to wtfpl license in README. [#2571](https://github.com/mmistakes/minimal-mistakes/pull/2571)
2222
- Ignore teaser headline in table of contents when including posts list in another page. [#2558](https://github.com/mmistakes/minimal-mistakes/pull/2558)
2323
- Replace Font Awesome Kits with CSS from jsDelivr CDN. [#2583](https://github.com/mmistakes/minimal-mistakes/pull/2583)
24+
- Add `danmaku` option to Bilibili video provider and add corresponding documentation/ [#2599](https://github.com/mmistakes/minimal-mistakes/pull/2599)
2425

2526
## [4.19.3](https://github.com/mmistakes/minimal-mistakes/releases/tag/4.19.3)
2627

0 commit comments

Comments
 (0)
Please sign in to comment.