From ec6fbc876830319c1c1b65e4dd72a561bc080a64 Mon Sep 17 00:00:00 2001 From: Alexander Fuks Date: Wed, 28 Feb 2024 00:51:33 +0400 Subject: [PATCH] feat: add support for embed video files (#1558) --- _includes/embed/bilibili.html | 7 +++-- _includes/embed/video.html | 38 +++++++++++++++++++++++++++ _includes/embed/youtube.html | 2 +- _posts/2019-08-08-write-a-new-post.md | 27 +++++++++++++++++++ _sass/addon/commons.scss | 18 +++++++++---- 5 files changed, 82 insertions(+), 10 deletions(-) create mode 100644 _includes/embed/video.html diff --git a/_includes/embed/bilibili.html b/_includes/embed/bilibili.html index eaa09d84..0aa5552d 100644 --- a/_includes/embed/bilibili.html +++ b/_includes/embed/bilibili.html @@ -1,10 +1,9 @@ \ No newline at end of file +> diff --git a/_includes/embed/video.html b/_includes/embed/video.html new file mode 100644 index 00000000..eb46c257 --- /dev/null +++ b/_includes/embed/video.html @@ -0,0 +1,38 @@ +{% assign video_url = include.src %} +{% assign poster_url = include.poster %} + +{% unless video_url contains '://' %} + {%- capture video_url -%} + {% include img-url.html src=video_url img_path=page.img_path %} + {%- endcapture -%} +{% endunless %} + +{% if poster_url %} + {% unless poster_url contains '://' %} + {%- capture poster_url -%} + {% include img-url.html src=poster_url img_path=page.img_path %} + {%- endcapture -%} + {% endunless %} + {% assign poster = 'poster="' | append: poster_url | append: '"' %} +{% endif %} + +{% assign attributes = 'controls' %} + +{% if include.autoplay %} + {% assign attributes = attributes | append: ' ' | append: 'autoplay' %} +{% endif %} + +{% if include.loop %} + {% assign attributes = attributes | append: ' ' | append: 'loop' %} +{% endif %} + +{% if include.muted %} + {% assign attributes = attributes | append: ' ' | append: 'muted' %} +{% endif %} + +

+ + {{ include.title }} +

diff --git a/_includes/embed/youtube.html b/_includes/embed/youtube.html index 640011f8..8f080021 100644 --- a/_includes/embed/youtube.html +++ b/_includes/embed/youtube.html @@ -1,5 +1,5 @@