Add YouTube playlist shortcode for embedding video series
This commit is contained in:
parent
6846053557
commit
5ead696bbd
1 changed files with 12 additions and 0 deletions
12
layouts/shortcodes/youtubepl.html
Normal file
12
layouts/shortcodes/youtubepl.html
Normal file
|
@ -0,0 +1,12 @@
|
|||
<!-- https://stackoverflow.com/questions/72065012/how-to-embed-a-youtube-playlist-in-hugo-website -->
|
||||
|
||||
{{- $pc := .Page.Site.Config.Privacy.YouTube -}}
|
||||
{{- if not $pc.Disable -}}
|
||||
{{- $ytHost := cond $pc.PrivacyEnhanced "www.youtube-nocookie.com" "www.youtube.com" -}}
|
||||
{{- $id := .Get "id" | default (.Get 0) -}}
|
||||
{{- $class := .Get "class" | default (.Get 1) -}}
|
||||
{{- $title := .Get "title" | default "YouTube Video" }}
|
||||
<div {{ with $class }}class="{{ . }}"{{ else }}style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;"{{ end }}>
|
||||
<iframe src="https://{{ $ytHost }}/embed/videoseries?list={{ $id }}{{ with .Get "autoplay" }}{{ if eq . "true" }}&autoplay=1{{ end }}{{ end }}" {{ if not $class }}style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" {{ end }}allowfullscreen title="{{ $title }}"></iframe>
|
||||
</div>
|
||||
{{ end -}}
|
Loading…
Add table
Add a link
Reference in a new issue