diff options
author | Nelson/Roberto <git@nelsonroberto.com> | 2022-02-11 23:33:24 +0300 |
---|---|---|
committer | Nelson/Roberto <git@nelsonroberto.com> | 2022-02-11 23:35:04 +0300 |
commit | 20ced025a6da9446cdcde1c2be90fd5d19157cb9 (patch) | |
tree | f77b4aa4c6ce4dac441e191c3c2d863f83fd4121 | |
parent | c780b9ede5372893ce73c888de3e75bf24d43dc9 (diff) |
Front page uses first image in page bundle as article image.
-rw-r--r-- | exampleSite/content/blog/post.10/banner.jpg | bin | 20737 -> 106067 bytes | |||
-rw-r--r-- | exampleSite/content/blog/post.10/pic03.jpg | bin | 0 -> 10897 bytes | |||
-rw-r--r-- | layouts/index.html | 2 | ||||
-rw-r--r-- | layouts/partials/bannerURL.html | 8 |
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 Binary files differindex b0206cb..246fdc8 100644 --- a/exampleSite/content/blog/post.10/banner.jpg +++ b/exampleSite/content/blog/post.10/banner.jpg diff --git a/exampleSite/content/blog/post.10/pic03.jpg b/exampleSite/content/blog/post.10/pic03.jpg Binary files differnew file mode 100644 index 0000000..237b96d --- /dev/null +++ b/exampleSite/content/blog/post.10/pic03.jpg 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 |