~xdavidwu/xdavidwu.link

e32b7c8880d3cfa534b3f707162d67f5004f018e — iBug ♦ 4 years ago a82b0cc
Enhance Bilibili video support (redo of #2522) (#2599)

* Enhance support for bilibili videos in responsive video helper, and add corresponding doc

* Apply @iBug's review in mmistakes/minimal-mistakes#2522

* Fix danmaku in page hero video

* Update video to use case..when for iframe src

* Update CHANGELOG and history

Co-authored-by: Anran <51769728+ALeafWolf@users.noreply.github.com>
Co-authored-by: Michael Rose <mmistakes@users.noreply.github.com>
3 files changed, 23 insertions(+), 15 deletions(-)

M CHANGELOG.md
M _includes/page__hero_video.html
M _includes/video
M CHANGELOG.md => CHANGELOG.md +1 -0
@@ 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)


M _includes/page__hero_video.html => _includes/page__hero_video.html +2 -4
@@ 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 %}

M _includes/video => _includes/video +20 -11
@@ 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 %}