Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Vimux/Binario.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVimux <Vimux@users.noreply.github.com>2019-09-24 17:50:06 +0300
committerGitHub <noreply@github.com>2019-09-24 17:50:06 +0300
commitefb650245f49585ddbb014e43916a2459b59eefb (patch)
tree586311c92fadf61ba3547ed0bf12ccc0ac4f7e9e /layouts
parent33bff944f23f404805cc76e3d97afb8845931019 (diff)
Improve featured image (#17)
WARNING: UPGRADE HUGO TO VERSION 0.54.0 OR LATER * post_thumbnail -> post_featured * Add url, alt, caption and credit params for featured * Add previewOnly param * Add styles for featured * Add fallback for thumbnail.* * Add "Featured Images" page * Show caption & credit on single pages only * Update README: add featured image guide * Bump Hugo min version because `reflect.IsMap` [0.38 -> 0.54.0]
Diffstat (limited to 'layouts')
-rw-r--r--layouts/_default/single.html2
-rw-r--r--layouts/_default/summary.html2
-rw-r--r--layouts/partials/post_featured.html41
-rw-r--r--layouts/partials/post_thumbnail.html13
4 files changed, 43 insertions, 15 deletions
diff --git a/layouts/_default/single.html b/layouts/_default/single.html
index 0f77667..ea1c1bc 100644
--- a/layouts/_default/single.html
+++ b/layouts/_default/single.html
@@ -2,7 +2,7 @@
<main class="main">
<div class="single block">
<article class="post">
- {{- partial "post_thumbnail.html" (dict "page" .) }}
+ {{- partial "post_featured.html" (dict "page" . "IsSingle" true) }}
{{- partial "post_meta.html" (dict "dot" . "class" "mb") }}
<h1 class="post__title">{{ .Title }}</h1>
{{- partial "post_toc.html" . }}
diff --git a/layouts/_default/summary.html b/layouts/_default/summary.html
index 67b3ee5..30596e5 100644
--- a/layouts/_default/summary.html
+++ b/layouts/_default/summary.html
@@ -1,5 +1,5 @@
<article class="post card__box block">
- {{- partial "post_thumbnail.html" (dict "page" . "link" .RelPermalink) }}
+ {{- partial "post_featured.html" (dict "page" . "link" .RelPermalink) }}
<h1 class="post__title title-excerpt"><a class="post__title-link" href="{{ .RelPermalink }}">{{ .Title }}</a></h1>
{{- with .Summary }}
<div class="post__content">{{ . }}</div>
diff --git a/layouts/partials/post_featured.html b/layouts/partials/post_featured.html
new file mode 100644
index 0000000..e38966e
--- /dev/null
+++ b/layouts/partials/post_featured.html
@@ -0,0 +1,41 @@
+{{- with .page.Resources.ByType "image" }}
+ {{- $link := $.link -}}
+ {{- $IsSingle := $.IsSingle -}}
+ {{- $match := $.page.Params.featured -}}
+ {{- $featuredMap := "" -}}
+
+ {{- $IsMap := reflect.IsMap $match -}}
+ {{- if $IsMap }}
+ {{- $featuredMap = $match -}}
+ {{- $match = $match.url -}}
+ {{- end }}
+
+ {{- $featured := .GetMatch ($match | default "{featured.*,thumbnail.*}") -}}
+ {{ if and $featured (not (and $IsSingle ($.page.Param "featured.previewOnly"))) }}
+ <figure class="post__featured featured">
+ {{- with $link }}<a class="featured__link" href="{{ . }}">{{ end }}
+ <img class="featured__img" src="{{ $featured.RelPermalink }}" alt="
+ {{- with $featuredMap -}}
+ {{- .alt | default $featured.Title -}}
+ {{- else -}}
+ {{- $featured.Title -}}
+ {{- end -}}
+ "/>
+ {{- with $link }}</a>{{ end }}
+ {{- with $IsSingle }}
+ {{- with $featuredMap }}
+ {{- if or .caption .credit }}
+ <figcaption class="featured__figcaption">
+ {{- with .caption }}
+ <div class="featured__caption">{{ . | markdownify }}</div>
+ {{- end }}
+ {{- with .credit }}
+ <cite class="featured__credit">{{ . | markdownify }}</cite>
+ {{- end }}
+ </figcaption>
+ {{- end }}
+ {{- end }}
+ {{- end }}
+ </figure>
+ {{- end }}
+{{- end }} \ No newline at end of file
diff --git a/layouts/partials/post_thumbnail.html b/layouts/partials/post_thumbnail.html
deleted file mode 100644
index 36899bc..0000000
--- a/layouts/partials/post_thumbnail.html
+++ /dev/null
@@ -1,13 +0,0 @@
-{{- $img := (.page.Resources.ByType "image").GetMatch "thumbnail.*" }}
-{{- $link := .link }}
-{{- with $img }}
- <figure class="post__thumbnail thumbnail">
- {{- with $link }}
- <a class="thumbnail__link" href="{{ . }}">
- <img class="thumbnail__img" src="{{ $img.RelPermalink }}" alt="{{ $img.Title }}">
- </a>
- {{- else }}
- <img class="thumbnail__img" src="{{ $img.RelPermalink }}" alt="{{ $img.Title }}">
- {{- end }}
- </figure>
-{{- end }} \ No newline at end of file