website/layouts/shortcodes/youtube.html
2024-09-07 16:25:42 +02:00

42 lines
1.2 KiB
HTML

{{ $code := "helloworld" }}
{{ if (.Get "code") }}
{{ $code = (.Get "code") }}
{{ else if (.Get "src") }}
{{ $code = (.Get "src") }}
{{ $code = (strings.ReplaceRE `(http(?:s)?:\/\/(?:www\.)?youtu(?:(?:be\.com)|(?:\.be))|(?:be-nocookie\.com))\/(?:(?:watch\?v=)|(?:embed\/)|(?:\/v\/))?(.+)?(?:\&|\?)` "" $code) }}
{{ end }}
{{ if (.Get "iframemode") }}
<center>
<iframe class="youtubelink" src="https://youtube.com/embed/{{ $code }}?cc_load_policy=1&cc_lang_pref=fr&hl=fr-FR&autohide=2&wmode=transparent" allowfullscreen="true"></iframe>
</center>
</center>
{{ else }}
<center>
<a class="youtubelink static" href="https://youtu.be/{{ $code }}"><img src="http://i3.ytimg.com/vi/{{ $code }}/hqdefault.jpg"/></a>
</center>
{{ end }}
<style>
.youtubelink{
display:block;
position:relative;
width:100%;
height:597px;
&.static{
&::after{
position:absolute;
display:block;
left:50%;
top:50%;
transform: translate(-50%, -50%);
width:20px;
height:20px;
content:"Play";
background: url(https://upload.wikimedia.org/wikipedia/commons/thumb/5/52/YouTube_social_white_circle_%282017%29.svg/1024px-YouTube_social_white_circle_%282017%29.svg.png);
}
img{
width:100%!important;
height:100%!important;
}
}
}
</style>