From e32b7c8880d3cfa534b3f707162d67f5004f018e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?iBug=20=E2=99=A6?= Date: Thu, 23 Jul 2020 03:42:46 +0800 Subject: [PATCH] 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 --- CHANGELOG.md | 1 + _includes/page__hero_video.html | 6 ++---- _includes/video | 31 ++++++++++++++++++++----------- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2c3209..7730eab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/_includes/page__hero_video.html b/_includes/page__hero_video.html index 8586a95..a313a23 100644 --- a/_includes/page__hero_video.html +++ b/_includes/page__hero_video.html @@ -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 %} diff --git a/_includes/video b/_includes/video index 04b37e0..d653fd6 100644 --- a/_includes/video +++ b/_includes/video @@ -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 %} -
-{% if video_provider == "vimeo" %} - -{% elsif video_provider == "youtube" %} - -{% elsif video_provider == "google-drive" %} - -{% elsif video_provider == "bilibili" %} - -{% endif %} -
+{% unless video_src == "" %} +
+ +
+{% endunless %} -- 2.45.2