mirror of
https://github.com/BBaoVanC/bobatheme.git
synced 2024-11-17 13:25:57 -06:00
Automatically add the featured media to individual posts
This commit is contained in:
parent
937a80bc17
commit
96067c95c0
@ -17,5 +17,9 @@
|
||||
|
||||
<hr>
|
||||
|
||||
{{ with .Resources.GetMatch "feature" }}
|
||||
{{ partial "featured_media.html" . }}
|
||||
{{ end }}
|
||||
|
||||
{{ .Content }}
|
||||
{{ end }}
|
||||
|
@ -12,24 +12,7 @@
|
||||
{{ partial "post-metadata.html" . }}
|
||||
|
||||
{{ with .Resources.GetMatch "feature" }}
|
||||
<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>
|
||||
{{ partial "featured_media.html" . }}
|
||||
{{ end }}
|
||||
|
||||
<div class="post-description">
|
||||
|
18
layouts/partials/featured_media.html
Normal file
18
layouts/partials/featured_media.html
Normal file
@ -0,0 +1,18 @@
|
||||
<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>
|
Loading…
Reference in New Issue
Block a user