diff options
author | cntrump <cntrump@gmail.com> | 2021-12-28 10:17:07 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-28 10:17:07 +0300 |
commit | f6ee0748940d3d29a4b7e21bdfa17d1a13f211bf (patch) | |
tree | 9569ac44d36b651ffb5cf2be6b47f979b7a725ee | |
parent | c015caa59a71b9d041737044d96cf78278f9ddc5 (diff) | |
parent | 1935e8fe3f3d08a79bf2bb07329acc8ec1c46791 (diff) |
Merge pull request #78 from mopig/feat-shortcodes-bilibili
feat: shortcodes support bilibili
-rw-r--r-- | README.md | 9 | ||||
-rw-r--r-- | layouts/shortcodes/bilibili.html | 24 |
2 files changed, 33 insertions, 0 deletions
@@ -26,6 +26,7 @@ Features - [Twitter Card](https://developer.twitter.com/en/docs/tweets/optimize-with-cards/overview/summary) supporting - Builtin iconfont (3KB) - Display author profile at article bottom +- Support Bilibili shortcodes Preview the exampleSite: @@ -183,6 +184,14 @@ When $a \ne 0$, there are two solutions to \(ax^2 + bx + c = 0\) and they are $$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$ ``` +### Bilibili shortcodes + +```html +{{< bilibili BV1FV411d7u7>}} +OR +{{< bilibili id="BV1FV411d7u7">}} +``` + ### Comments Setup Disqus [shortname](https://help.disqus.com/en/articles/1717111-what-s-a-shortname) in config.toml: diff --git a/layouts/shortcodes/bilibili.html b/layouts/shortcodes/bilibili.html new file mode 100644 index 0000000..17ebdda --- /dev/null +++ b/layouts/shortcodes/bilibili.html @@ -0,0 +1,24 @@ +<div class="video_wrapper" style="position: relative; padding-bottom: 75%;"> + {{- $bvid := "" -}} + {{if .Get "id"}} + {{$bvid = .Get "id"}} + {{else if .Get 0}} + {{$bvid = .Get 0}} + {{end}} + {{if $bvid}} + <iframe + style="position: absolute; top: 0; left: 0;" + width="100%" + height="100%" + src="//player.bilibili.com/player.html?aid=123456&bvid={{ $bvid }}&cid=123456&page=1" + scrolling="no" + border="0" + frameborder="no" + framespacing="0" + allowfullscreen="true" + > + </iframe> + {{else}} + <h6>请填写视频 url 中的视频 id,例如:BV1FV411d7u7</h6> + {{end}} +</div> |