website/layouts/shortcodes/youtube.html

47 lines
1.3 KiB
HTML
Raw Normal View History

2024-05-17 20:35:54 +02:00
{{ $code := "helloworld" }}
{{ if (.Get "code") }}
{{ $code = (.Get "code") }}
{{ else if (.Get "src") }}
{{ $code = (.Get "src") }}
2024-05-18 18:17:10 +02:00
{{ $code = (strings.ReplaceRE `(http(?:s)?:\/\/(?:www\.)?youtu(?:(?:be\.com)|(?:\.be))|(?:be-nocookie\.com))\/(?:(?:watch\?v=)|(?:embed\/)|(?:\/v\/))?(.+)?(?:\&|\?)` "" $code) }}
2024-05-17 20:35:54 +02:00
{{ end }}
2024-09-07 16:05:00 +02:00
{{ if (.Get "iframemode") }}
<center>
2024-09-07 16:18:29 +02:00
<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>
2024-09-07 16:05:00 +02:00
</center>
</center>
{{ else }}
<center>
2024-09-07 16:18:29 +02:00
<a class="youtubelink static" href="https://youtu.be/{{ $code }}"><img src="http://i3.ytimg.com/vi/{{ $code }}/hqdefault.jpg"/></a>
2024-09-07 16:05:00 +02:00
</center>
{{ end }}
<style>
.youtubelink{
2024-09-07 16:22:06 +02:00
display:block;
2024-09-07 16:25:42 +02:00
position:relative;
2024-09-07 16:05:00 +02:00
width:100%;
2024-09-07 16:20:34 +02:00
height:597px;
2024-09-07 16:23:52 +02:00
&.static{
&::after{
2024-09-07 16:39:36 +02:00
display: flex;
justify-content: center;
align-items: center;
2024-09-07 16:33:03 +02:00
position:absolute;
left:50%;
top:50%;
transform: translate(-50%, -50%);
width:80px;
height:80px;
content:"Play on youtube";
2024-09-07 16:41:22 +02:00
color:white;
background: linear-gradient( rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5) ), url(/youtube.svg);
2024-09-07 16:33:03 +02:00
background-size:cover;
2024-09-07 16:23:52 +02:00
}
img{
width:100%!important;
height:100%!important;
}
2024-09-07 16:18:29 +02:00
}
2024-09-07 16:05:00 +02:00
}
</style>