mirror of
https://github.com/BBaoVanC/bobatheme.git
synced 2025-07-07 12:37:31 -05:00
WIP
This commit is contained in:
21
layouts/_partials/embed-resource.html
Normal file
21
layouts/_partials/embed-resource.html
Normal 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 }}
|
10
layouts/_partials/feature-figure.html
Normal file
10
layouts/_partials/feature-figure.html
Normal 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 }}
|
@ -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>
|
@ -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>
|
Reference in New Issue
Block a user