Still alive.
Today: Removing YouTube embedding. I saw something cool in the AAMSX web,
so I decided to copy that. The idea was to use
Lite YouTube,
however… I got many errors regarding the CSP (Content Security Policy), as it
is set to null
and it was, again, including JavaScript. So fuck it.
So instead I did this Hugo shortcode:
{{- $videoId := trim (.Get 0) " " -}}
<youtube-thumb videoid="{{ $videoId }}">
<a href="https://www.youtube.com/watch?v={{ $videoId }}" target="_blank"><img
src="https://i.ytimg.com/vi/{{ $videoId }}/hqdefault.jpg" alt="YouTube
Link" style="border: #FFFFFF 4px double;"></a>
<p><center><small>Click to watch in YouTube (New tab)</small></center></p>
</youtube-thumb>
And if you put this in layouts/shortcodes/youtube-thumb.html
, you’ll be able
to use it as {{< youtube-thumb VIDEO_ID >}} and you’ll get the video thumbnail
in JPG and be able to click on it to watch it. The target="_blank"
makes it to
open a new tab. I kind of like it. It’s less functional compared to lite youtube
, but it works and it does not add JavaScript on our side.