This commit is contained in:
2025-07-06 19:44:46 -05:00
parent 1f82ad4f0b
commit 8fafc843ef
12 changed files with 55 additions and 95 deletions

View File

@ -0,0 +1,21 @@
{{ if eq .ResourceType "image" }}
{{/* TODO: figure out whether loading="lazy" should be set because MDN
* claims that images won't work with JS disabled since it would
* make tracking possible, but my experience says otherwise
*/}}
<img src="{{ .Permalink }}" {{ with .Params.alt }}alt="{{ . }}"{{ end }} />
{{ else if eq .ResourceType "video" }}
<video controls preload="metadata">
{{/* FIXME
<source src="{{ .Permalink }}" {{ with .Params.alt }}alt="{{ . }}"{{ end }} />
*/}}
{{ i18n "browser_no_video_support" }}
<a href="{{ .Permalink }}" target="_blank" rel="noopener">
{{ i18n "browser_no_video_support_link" }}
</video>
{{ else }}
{{/* TODO: could consider implementing more types, listed at:
* https://www.iana.org/assignments/media-types/media-types.xhtml
*/}}
{{ errorf "Handling %q resource not supported" .ResourceType }}
{{ end }}

View File

@ -0,0 +1,10 @@
{{ with .Resources.Get "feature" }}
<div class="post-media">
<figure>
{{ partial "embed-resource.html" . }}
{{ with .Title }}
<figcaption>{{ . }}</figcaption>
{{ end }}
</figure>
</div>
{{ end }}

View File

@ -1,27 +0,0 @@
{{ $hidecaption := index . "hidecaption" }}
{{ if index . "noborder" }}
<figure>
{{ else }}
<figure class="border">
{{ end }}
{{ with index . "src" }}
{{ if eq .MediaType.MainType "image" }}
<img src="{{ .Permalink }}" alt="{{ .Title }}" loading="lazy" />
{{ else if eq .MediaType.MainType "video" }}
<video controls preload="metadata">
<source src="{{ .Permalink }}" alt="{{ .Title }}">
{{ i18n "browser_no_video_support" }}
</video>
{{ end }}
{{ if not $hidecaption }}
{{ with .Title }}
<figcaption>
{{ . | markdownify }}
</figcaption>
{{ end }}
{{ end }}
{{ end }}
</figure>

View File

@ -1,28 +0,0 @@
{{ $hidecaption := index . "hidecaption" }}
{{ $type := index . "type" }}
{{ $src := index . "src" }}
{{ $alt := index . "alt" }}
{{ if index . "border" }}
<figure class="border">
{{ else }}
<figure>
{{ end }}
{{ if eq $type "image" }}
<img src="{{ $src }}" alt="{{ $alt }}" loading="lazy" />
{{ else if eq $type "video" }}
<video controls preload="metadata">
<source src="{{ $src }}" alt="{{ $alt }}">
{{ i18n "browser_no_video_support" }}
</video>
{{ end }}
{{ if not $hidecaption }}
{{ with $alt }}
<figcaption>
{{ . | markdownify }}
</figcaption>
{{ end }}
{{ end }}
</figure>