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 }}
description: ""
categories: []
featuredImage: ""
featuredImageDescription: ""
dropCap: true
displayInMenu: false
displayInList: 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)"
href="{{ .Permalink }}" class="card blog-card" rel="bookmark" >
{{ if isset .Params "featuredimage" }}
{{ with .Resources.GetMatch "featuredImage" }}
<div class="card-img-container">
<p class="card-img-overlay">Next Article</p>
<picture>
{{ if (fileExists (printf "%s/%s" "static" (replace (.Params.featuredimage) (path.Ext .Params.featuredimage) ".webp"))) -}}
<source srcset="{{ replace (.Params.featuredimage) (path.Ext (.Params.featuredimage)) ".webp" | absURL }}" type="image/webp">
{{ with $.Resources.GetMatch (replace (.Title) (path.Ext (.Title)) ".webp") -}}
<source srcset="{{ .Permalink }}" type="image/webp">
{{- end }}
<source srcset="{{ .Params.featuredimage | absURL }}">
<img src="{{.Params.featuredimage | absURL }}" class="card-img" {{ if isset .Params "featuredimagedescription" }}alt="{{.Params.featuredimagedescription}}"{{end}}>
<source srcset="{{ .Permalink }}">
<img src="{{ .Permalink }}" class="card-img" {{ with .Params.description -}} alt="{{ . }}" {{- end }}>
</picture>
</div>
{{ end }}

View File

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

View File

@@ -9,13 +9,13 @@
<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>
</header>
{{ if isset .Params "featuredimage" }}
{{ with .Resources.GetMatch "featuredImage" }}
<picture class="post-figure">
{{ if (fileExists (printf "%s/%s" "static" (replace (.Params.featuredimage) (path.Ext (.Params.featuredimage)) ".webp"))) -}}
<source srcset="{{ replace (.Params.featuredimage) (path.Ext (.Params.featuredimage)) ".webp" | absURL }}" type="image/webp">
{{ with $.Resources.GetMatch (replace (.Title) (path.Ext (.Title)) ".webp") -}}
<source srcset="{{ .Permalink }}" type="image/webp">
{{- end }}
<source srcset="{{.Params.featuredimage | absURL }}">
<img src="{{.Params.featuredimage | absURL }}" {{ if isset .Params "featuredimagedescription" }}alt="{{.Params.featuredimagedescription}}"{{end}}>
<source srcset="{{ .Permalink }}">
<img src="{{ .Permalink }}" {{ with .Params.description -}} alt="{{ . }}" {{- end }}>
</picture>
{{ end }}
{{ .Content }}