{{/* 视频嵌入 shortcode(简约风格) 用法: {{< video src="xxx.mp4" >}} {{< video src="xxx.mp4" poster="cover.jpg" caption="说明" >}} {{< bilibili BV1xx411c7mD >}} {{< youtube dQw4w9WgXcQ >}} */}} {{ if .Get "bvid" | or (.Get 0) }} {{/* Bilibili */}} {{ $bvid := .Get "bvid" | default (.Get 0) }}
{{ else if .Get "id" | or (and (.Get 0) (not (.Get "src"))) }} {{/* YouTube */}} {{ $id := .Get "id" | default (.Get 0) }}
{{ else }} {{/* 本地/外部视频 */}} {{ $src := .Get "src" }} {{ $poster := .Get "poster" }} {{ $caption := .Get "caption" }} {{ $loop := .Get "loop" | default "false" }} {{ $muted := .Get "muted" | default "false" }} {{ $isGifMode := or (eq $loop "true") (eq $muted "true") }} {{ $videoSrc := $src }} {{ if not (hasPrefix $src "http") }} {{ $videoSrc = printf "/%s/%s" .Page.Slug $src }} {{ end }}
{{ if not $isGifMode }}
0:00
{{ end }}
{{ with $caption }}
{{ . }}
{{ end }}
{{ end }}