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

github.com/dewittn/hugo-html5up-alpha.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNelson/Roberto <git@nelsonroberto.com>2022-02-11 23:33:24 +0300
committerNelson/Roberto <git@nelsonroberto.com>2022-02-11 23:35:04 +0300
commit20ced025a6da9446cdcde1c2be90fd5d19157cb9 (patch)
treef77b4aa4c6ce4dac441e191c3c2d863f83fd4121
parentc780b9ede5372893ce73c888de3e75bf24d43dc9 (diff)
Front page uses first image in page bundle as article image.
-rw-r--r--exampleSite/content/blog/post.10/banner.jpgbin20737 -> 106067 bytes
-rw-r--r--exampleSite/content/blog/post.10/pic03.jpgbin0 -> 10897 bytes
-rw-r--r--layouts/index.html2
-rw-r--r--layouts/partials/bannerURL.html8
4 files changed, 7 insertions, 3 deletions
diff --git a/exampleSite/content/blog/post.10/banner.jpg b/exampleSite/content/blog/post.10/banner.jpg
index b0206cb..246fdc8 100644
--- a/exampleSite/content/blog/post.10/banner.jpg
+++ b/exampleSite/content/blog/post.10/banner.jpg
Binary files differ
diff --git a/exampleSite/content/blog/post.10/pic03.jpg b/exampleSite/content/blog/post.10/pic03.jpg
new file mode 100644
index 0000000..237b96d
--- /dev/null
+++ b/exampleSite/content/blog/post.10/pic03.jpg
Binary files differ
diff --git a/layouts/index.html b/layouts/index.html
index db5a2d3..5cdd6a9 100644
--- a/layouts/index.html
+++ b/layouts/index.html
@@ -71,7 +71,7 @@
<div class="row">
{{ range first .postCount (where site.RegularPages "Type" "in" site.Params.mainSections) }}
<div class="col-6 col-12-narrower">
- <section class="box special">
+ <section class="box special">
{{ with partial "bannerURL" . }}
<span class="image featured"><img src="{{ . }}" alt="" /></span>
{{ end }}
diff --git a/layouts/partials/bannerURL.html b/layouts/partials/bannerURL.html
index 4f2abfa..ed467f2 100644
--- a/layouts/partials/bannerURL.html
+++ b/layouts/partials/bannerURL.html
@@ -1,7 +1,11 @@
{{ $bannerURL := "" }}
{{ if .Params.image }}
{{ $bannerURL = (.Params.image | relURL) }}
-{{ else if .Resources.GetMatch "banner.jpg" }}
- {{ $bannerURL = (.Resources.GetMatch "banner.jpg").Permalink }}
+{{ else }}
+ {{ with first 1 (.Resources.ByType "image") }}
+ {{ range . }}
+ {{ $bannerURL = .RelPermalink }}
+ {{ end }}
+ {{ end }}
{{ end }}
{{ return $bannerURL }} \ No newline at end of file