diff --git a/layouts/shortcodes/audio.html b/layouts/shortcodes/audio.html new file mode 100644 index 0000000..0b2a583 --- /dev/null +++ b/layouts/shortcodes/audio.html @@ -0,0 +1,27 @@ +{{ $src := .Get "src" | strings.TrimSpace }} +{{ $title := .Get "title" | strings.TrimSpace }} +{{ $types := split (.Get "types" | default "") "|" }} + +{{ if not (strings.Contains $src "://") }} + {{ $src = relURL $src }} +{{ end }} + +
+ + {{ with $title }} + {{ . }} + {{ end }} +
\ No newline at end of file diff --git a/layouts/shortcodes/bilibili.html b/layouts/shortcodes/bilibili.html new file mode 100644 index 0000000..3cf1ffa --- /dev/null +++ b/layouts/shortcodes/bilibili.html @@ -0,0 +1,9 @@ + diff --git a/layouts/shortcodes/video.html b/layouts/shortcodes/video.html new file mode 100644 index 0000000..31f3de2 --- /dev/null +++ b/layouts/shortcodes/video.html @@ -0,0 +1,45 @@ +{{- $src := .Get "src" -}} +{{- $title := .Get "title" -}} +{{- $poster := .Get "poster" -}} +{{- $types := split (.Get "types" | default "") "|" -}} + +{{- /* Process video URL */ -}} +{{- if not (strings.Contains $src "://") -}} + {{- $src = relURL $src -}} +{{- end -}} + +{{- /* Process poster URL */ -}} +{{- $posterAttr := "" -}} +{{- if $poster -}} + {{- if not (strings.Contains $poster "://") -}} + {{- $poster = relURL $poster -}} + {{- end -}} + {{- $posterAttr = printf `poster="%s"` $poster -}} +{{- end -}} + +{{- /* Build attributes */ -}} +{{- $attributes := slice "controls" -}} +{{- if .Get "autoplay" -}}{{- $attributes = $attributes | append "autoplay" -}}{{- end -}} +{{- if .Get "loop" -}}{{- $attributes = $attributes | append "loop" -}}{{- end -}} +{{- if .Get "muted" -}}{{- $attributes = $attributes | append "muted" -}}{{- end -}} +{{- $attributes = delimit $attributes " " -}} + +