Automatically add the featured media to individual posts

This commit is contained in:
BBaoVanC 2021-10-19 14:01:35 -05:00
parent 937a80bc17
commit 96067c95c0
Signed by: bbaovanc
GPG Key ID: 18089E4E3CCF1D3A
3 changed files with 23 additions and 18 deletions

View File

@ -17,5 +17,9 @@
<hr>
{{ with .Resources.GetMatch "feature" }}
{{ partial "featured_media.html" . }}
{{ end }}
{{ .Content }}
{{ end }}

View File

@ -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">

View 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>