Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance Bilibili video support (redo of #2522) #2599

Merged
merged 6 commits into from
Jul 22, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
- Update link to wtfpl license in README. [#2571](https://github.com/mmistakes/minimal-mistakes/pull/2571)
- Ignore teaser headline in table of contents when including posts list in another page. [#2558](https://github.com/mmistakes/minimal-mistakes/pull/2558)
- Replace Font Awesome Kits with CSS from jsDelivr CDN. [#2583](https://github.com/mmistakes/minimal-mistakes/pull/2583)
- Add `danmaku` option to Bilibili video provider and add corresponding documentation/ [#2599](https://github.com/mmistakes/minimal-mistakes/pull/2599)

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

6 changes: 2 additions & 4 deletions _includes/page__hero_video.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
{% capture video_id %}{{ page.header.video.id }}{% endcapture %}
{% capture video_provider %}{{ page.header.video.provider }}{% endcapture %}

{% include video id=video_id provider=video_provider %}
{% assign video = page.header.video %}
{% include video id=video.id provider=video.provider danmaku=video.danmaku %}
31 changes: 20 additions & 11 deletions _includes/video
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
{% capture video_id %}{{ include.id }}{% endcapture %}
{% capture video_provider %}{{ include.provider }}{% endcapture %}
{% capture video_danmaku %}{{ include.danmaku | default: 0 }}{% endcapture %}

{% capture video_src %}
{% case video_provider %}
{% when "vimeo" %}
https://player.vimeo.com/video/{{ video_id }}?dnt=true
{% when "youtube" %}
https://www.youtube-nocookie.com/embed/{{ video_id }}
{% when "google-drive" %}
https://drive.google.com/file/d/{{ video_id }}/preview
{% when "bilibili" %}
https://player.bilibili.com/player.html?bvid={{ video_id }}&page=1&as_wide=1&high_quality=1&danmaku={{ video_danmaku }}
{% endcase %}
{% endcapture %}
{% assign video_src = video_src | strip %}

<!-- Courtesy of embedresponsively.com //-->
<div class="responsive-video-container">
{% if video_provider == "vimeo" %}
<iframe src="https://player.vimeo.com/video/{{ video_id }}?dnt=true" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
{% elsif video_provider == "youtube" %}
<iframe src="https://www.youtube-nocookie.com/embed/{{ video_id }}" frameborder="0" allowfullscreen></iframe>
{% elsif video_provider == "google-drive" %}
<iframe src="https://drive.google.com/file/d/{{ video_id }}/preview" frameborder="0" allowfullscreen></iframe>
{% elsif video_provider == "bilibili" %}
<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>
{% endif %}
</div>
{% unless video_src == "" %}
<div class="responsive-video-container">
<iframe src="{{ video_src }}" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowfullscreen></iframe>
</div>
{% endunless %}
25 changes: 25 additions & 0 deletions docs/_docs/14-helpers.md
Original file line number Diff line number Diff line change
@@ -179,6 +179,7 @@ Embed a video from YouTube, Vimeo, Google Drive, or bilibili that responsively s
| ---------- | ------------ | ---------------------------------------------------------- |
| `id` | **Required** | ID of the video |
| `provider` | **Required** | Hosting provider of the video: `youtube`, `vimeo`, `google-drive`, or `bilibili` |
| `danmaku` | Optional | Bilibili only, [details below](#Bilibili) |

### YouTube

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

### Bilibili

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:

```liquid
{% raw %}{% include video id="BV1E7411e7hC" provider="bilibili" %}{% endraw %}
```

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:

```liquid
{% raw %}{% include video id="BV1E7411e7hC" provider="bilibili" danmaku="1" %}{% endraw %}
```

To embed it as a video header you'd use the following YAML Front Matter:

```yaml
header:
video:
id: BV1E7411e7hC
provider: bilibili
danmaku: 1
```

## Table of contents

Auto-generated table of contents list for your posts and pages can be enabled using two methods.
3 changes: 2 additions & 1 deletion docs/_docs/18-history.md
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ permalink: /docs/history/
excerpt: "Change log of enhancements and bug fixes made to the theme."
sidebar:
nav: docs
last_modified_at: 2020-07-22T15:36:16-04:00
last_modified_at: 2020-07-11T12:31:08+08:00
toc: false
---

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

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