mirror of
https://github.com/BBaoVanC/bobatheme.git
synced 2024-11-17 13:25:57 -06:00
Use a single figure shortcode that does either image or video
This commit is contained in:
parent
96067c95c0
commit
b599ddeadd
@ -18,7 +18,9 @@
|
||||
<hr>
|
||||
|
||||
{{ with .Resources.GetMatch "feature" }}
|
||||
{{ partial "featured_media.html" . }}
|
||||
<div class="post-media">
|
||||
{{ partial "figure.html" . }}
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
{{ .Content }}
|
||||
|
@ -12,7 +12,9 @@
|
||||
{{ partial "post-metadata.html" . }}
|
||||
|
||||
{{ with .Resources.GetMatch "feature" }}
|
||||
{{ partial "featured_media.html" . }}
|
||||
<div class="post-media">
|
||||
{{ partial "figure.html" . }}
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
<div class="post-description">
|
||||
|
@ -1,18 +0,0 @@
|
||||
<div class="post-media">
|
||||
<figure>
|
||||
{{ $media := . | resources.Fingerprint "sha512" }}
|
||||
{{ if eq .MediaType.MainType "image" }}
|
||||
<img src="{{ $media.Permalink }}" alt="{{ $media.Title }}" />
|
||||
{{ else if eq .MediaType.MainType "video" }}
|
||||
<video controls>
|
||||
<source src="{{ $media.Permalink }}" alt="{{ $media.Title }}">
|
||||
</video>
|
||||
{{ end }}
|
||||
|
||||
{{ with $media.Title }}
|
||||
<figcaption>
|
||||
{{ . | markdownify }}
|
||||
</figcaption>
|
||||
{{ end }}
|
||||
</figure>
|
||||
</div>
|
17
layouts/partials/figure.html
Normal file
17
layouts/partials/figure.html
Normal file
@ -0,0 +1,17 @@
|
||||
<figure>
|
||||
{{ $media := . | resources.Fingerprint "sha512" }}
|
||||
{{ if eq .MediaType.MainType "image" }}
|
||||
<img src="{{ $media.Permalink }}" alt="{{ $media.Title }}" />
|
||||
{{ else if eq .MediaType.MainType "video" }}
|
||||
<video controls>
|
||||
<source src="{{ $media.Permalink }}" alt="{{ $media.Title }}">
|
||||
{{ i18n "browser_no_video_support" }}
|
||||
</video>
|
||||
{{ end }}
|
||||
|
||||
{{ with $media.Title }}
|
||||
<figcaption>
|
||||
{{ . | markdownify }}
|
||||
</figcaption>
|
||||
{{ end }}
|
||||
</figure>
|
@ -1,22 +0,0 @@
|
||||
<figure>
|
||||
|
||||
{{ $img := $.Page.Resources.GetMatch (.Get "src") | resources.Fingerprint "sha512" }}
|
||||
|
||||
{{ if .Get "href" }}<a href="{{ .Get "href" }}">{{ end }}
|
||||
<img src="{{ $img.Permalink }}"
|
||||
{{ with $img.Title }}
|
||||
alt="{{ . }}"
|
||||
{{ end }}
|
||||
|
||||
{{ with .Get "width" }}width="{{ . }}"{{ end }}
|
||||
{{ with .Get "height" }}height="{{ . }}"{{ end }}
|
||||
/>
|
||||
{{ if .Get "href" }}</a>{{ end }}
|
||||
|
||||
{{ with $img.Title }}
|
||||
<figcaption>
|
||||
{{ . | markdownify }}
|
||||
</figcaption>
|
||||
{{ end }}
|
||||
|
||||
</figure>
|
2
layouts/shortcodes/figure.html
Normal file
2
layouts/shortcodes/figure.html
Normal file
@ -0,0 +1,2 @@
|
||||
{{ $resource := $.Page.Resources.GetMatch (.Get "src") }}
|
||||
{{ partial "figure.html" $resource }}
|
@ -1,18 +0,0 @@
|
||||
<figure>
|
||||
|
||||
{{ $vid := $.Page.Resources.GetMatch (.Get "src") | resources.Fingerprint "sha512" }}
|
||||
|
||||
{{ if .Get "href" }}<a href="{{ .Get "href" }}">{{ end }}
|
||||
<video controls>
|
||||
<source src="{{ $vid.Permalink }}" alt="{{ $vid.Title }}">
|
||||
{{ i18n "browser_no_video_support" }}
|
||||
</video>
|
||||
{{ if .Get "href" }}</a>{{ end }}
|
||||
|
||||
{{ with $vid.Title }}
|
||||
<figcaption>
|
||||
{{ . | markdownify }}
|
||||
</figcaption>
|
||||
{{ end }}
|
||||
|
||||
</figure>
|
Loading…
Reference in New Issue
Block a user