Update featuredImage to use page bundle approach

This commit is contained in:
Joe Hutchinson
2019-07-17 14:06:28 -04:00
parent f909d2f5d4
commit 85960b6fa3
4 changed files with 34 additions and 31 deletions

View File

@@ -3,10 +3,13 @@ title: "{{ replace .TranslationBaseName "-" " " | title }}"
date: {{ .Date }} date: {{ .Date }}
description: "" description: ""
categories: [] categories: []
featuredImage: ""
featuredImageDescription: ""
dropCap: true dropCap: true
displayInMenu: false displayInMenu: false
displayInList: true displayInList: true
draft: true draft: true
resources:
- name: featuredImage
src: ""
params:
description: ""
--- ---

View File

@@ -1,14 +1,14 @@
<a ontouchstart="cardPressed.call(this)" ontouchend="cardReleased.call(this)" ontouchmove="cardReleased.call(this)" <a ontouchstart="cardPressed.call(this)" ontouchend="cardReleased.call(this)" ontouchmove="cardReleased.call(this)"
href="{{ .Permalink }}" class="card blog-card" rel="bookmark" > href="{{ .Permalink }}" class="card blog-card" rel="bookmark" >
{{ if isset .Params "featuredimage" }} {{ with .Resources.GetMatch "featuredImage" }}
<div class="card-img-container"> <div class="card-img-container">
<p class="card-img-overlay">Next Article</p> <p class="card-img-overlay">Next Article</p>
<picture> <picture>
{{ if (fileExists (printf "%s/%s" "static" (replace (.Params.featuredimage) (path.Ext .Params.featuredimage) ".webp"))) -}} {{ with $.Resources.GetMatch (replace (.Title) (path.Ext (.Title)) ".webp") -}}
<source srcset="{{ replace (.Params.featuredimage) (path.Ext (.Params.featuredimage)) ".webp" | absURL }}" type="image/webp"> <source srcset="{{ .Permalink }}" type="image/webp">
{{- end }} {{- end }}
<source srcset="{{ .Params.featuredimage | absURL }}"> <source srcset="{{ .Permalink }}">
<img src="{{.Params.featuredimage | absURL }}" class="card-img" {{ if isset .Params "featuredimagedescription" }}alt="{{.Params.featuredimagedescription}}"{{end}}> <img src="{{ .Permalink }}" class="card-img" {{ with .Params.description -}} alt="{{ . }}" {{- end }}>
</picture> </picture>
</div> </div>
{{ end }} {{ end }}

View File

@@ -1,13 +1,13 @@
<a ontouchstart="cardPressed.call(this)" ontouchend="cardReleased.call(this)" ontouchmove="cardReleased.call(this)" <a ontouchstart="cardPressed.call(this)" ontouchend="cardReleased.call(this)" ontouchmove="cardReleased.call(this)"
href="{{ .Permalink }}" class="card blog-card" rel="bookmark" > href="{{ .Permalink }}" class="card blog-card" rel="bookmark" >
{{ if isset .Params "featuredimage" -}} {{ with .Resources.GetMatch "featuredImage" }}
<div class="card-img-container"> <div class="card-img-container">
<picture> <picture>
{{ if (fileExists (printf "%s/%s" "static" (replace (.Params.featuredimage) (path.Ext .Params.featuredimage) ".webp"))) -}} {{ with $.Resources.GetMatch (replace (.Title) (path.Ext (.Title)) ".webp") -}}
<source srcset="{{ replace (.Params.featuredimage) (path.Ext (.Params.featuredimage)) ".webp" | absURL }}" type="image/webp"> <source srcset="{{ .Permalink }}" type="image/webp">
{{- end }} {{- end }}
<source srcset="{{ .Params.featuredimage | absURL }}"> <source srcset="{{ .Permalink }}">
<img src="{{.Params.featuredimage | absURL }}" class="card-img" {{ if isset .Params "featuredimagedescription" }}alt="{{.Params.featuredimagedescription}}"{{end}}> <img src="{{ .Permalink }}" class="card-img" {{ with .Params.description -}} alt="{{ . }}" {{- end }}>
</picture> </picture>
</div> </div>
{{- end }} {{- end }}

View File

@@ -9,13 +9,13 @@
<h1 class="post-title">{{ .Title }}</h1> <h1 class="post-title">{{ .Title }}</h1>
<p class="post-date">Posted <time datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "Jan 2, 2006" }}</time></p> <p class="post-date">Posted <time datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "Jan 2, 2006" }}</time></p>
</header> </header>
{{ if isset .Params "featuredimage" }} {{ with .Resources.GetMatch "featuredImage" }}
<picture class="post-figure"> <picture class="post-figure">
{{ if (fileExists (printf "%s/%s" "static" (replace (.Params.featuredimage) (path.Ext (.Params.featuredimage)) ".webp"))) -}} {{ with $.Resources.GetMatch (replace (.Title) (path.Ext (.Title)) ".webp") -}}
<source srcset="{{ replace (.Params.featuredimage) (path.Ext (.Params.featuredimage)) ".webp" | absURL }}" type="image/webp"> <source srcset="{{ .Permalink }}" type="image/webp">
{{- end }} {{- end }}
<source srcset="{{.Params.featuredimage | absURL }}"> <source srcset="{{ .Permalink }}">
<img src="{{.Params.featuredimage | absURL }}" {{ if isset .Params "featuredimagedescription" }}alt="{{.Params.featuredimagedescription}}"{{end}}> <img src="{{ .Permalink }}" {{ with .Params.description -}} alt="{{ . }}" {{- end }}>
</picture> </picture>
{{ end }} {{ end }}
{{ .Content }} {{ .Content }}