diff options
author | Hugo Aguirre <hugo.agmtz@gmail.com> | 2020-10-19 04:19:09 +0300 |
---|---|---|
committer | Hugo Aguirre <hugo.agmtz@gmail.com> | 2020-10-19 04:19:09 +0300 |
commit | 60617b3335d89a1dab05a499c002003ec176140d (patch) | |
tree | 83a12d343ea6247ccf13973e4c05a1c65d2af477 | |
parent | ac2ac3b37595696d7aa93a4a4024e4012bbaad77 (diff) |
Get featured image on posts using page resources
-rw-r--r-- | exampleSite/content/posts/documentation/image-5.png (renamed from static/images/image-5.png) | bin | 5043 -> 5043 bytes | |||
-rw-r--r-- | exampleSite/content/posts/documentation/index.md (renamed from exampleSite/content/posts/documentation.md) | 0 | ||||
-rw-r--r-- | exampleSite/content/posts/elements/image-4.png (renamed from static/images/image-4.png) | bin | 5227 -> 5227 bytes | |||
-rw-r--r-- | exampleSite/content/posts/elements/index.md (renamed from exampleSite/content/posts/elements.markdown) | 0 | ||||
-rw-r--r-- | exampleSite/content/posts/installation/image-3.png (renamed from static/images/image-3.png) | bin | 5273 -> 5273 bytes | |||
-rw-r--r-- | exampleSite/content/posts/installation/index.md (renamed from exampleSite/content/posts/installation.markdown) | 2 | ||||
-rw-r--r-- | exampleSite/content/posts/no-image/index.md (renamed from exampleSite/content/posts/no-image.markdown) | 2 | ||||
-rw-r--r-- | exampleSite/content/posts/usage/image-2.png (renamed from static/images/image-2.png) | bin | 5444 -> 5444 bytes | |||
-rw-r--r-- | exampleSite/content/posts/usage/index.md (renamed from exampleSite/content/posts/usage.markdown) | 2 | ||||
-rw-r--r-- | exampleSite/content/posts/welcome-to-hugo/image-1.png (renamed from static/images/image-1.png) | bin | 5306 -> 5306 bytes | |||
-rw-r--r-- | exampleSite/content/posts/welcome-to-hugo/index.md (renamed from exampleSite/content/posts/welcome-to-hugo.markdown) | 2 | ||||
-rw-r--r-- | layouts/_default/list.html | 6 |
12 files changed, 9 insertions, 5 deletions
diff --git a/static/images/image-5.png b/exampleSite/content/posts/documentation/image-5.png Binary files differindex 46520dd..46520dd 100644 --- a/static/images/image-5.png +++ b/exampleSite/content/posts/documentation/image-5.png diff --git a/exampleSite/content/posts/documentation.md b/exampleSite/content/posts/documentation/index.md index fac87f7..fac87f7 100644 --- a/exampleSite/content/posts/documentation.md +++ b/exampleSite/content/posts/documentation/index.md diff --git a/static/images/image-4.png b/exampleSite/content/posts/elements/image-4.png Binary files differindex f7f46e8..f7f46e8 100644 --- a/static/images/image-4.png +++ b/exampleSite/content/posts/elements/image-4.png diff --git a/exampleSite/content/posts/elements.markdown b/exampleSite/content/posts/elements/index.md index dafacbe..dafacbe 100644 --- a/exampleSite/content/posts/elements.markdown +++ b/exampleSite/content/posts/elements/index.md diff --git a/static/images/image-3.png b/exampleSite/content/posts/installation/image-3.png Binary files differindex afd37c2..afd37c2 100644 --- a/static/images/image-3.png +++ b/exampleSite/content/posts/installation/image-3.png diff --git a/exampleSite/content/posts/installation.markdown b/exampleSite/content/posts/installation/index.md index c12ee67..3565660 100644 --- a/exampleSite/content/posts/installation.markdown +++ b/exampleSite/content/posts/installation/index.md @@ -2,7 +2,7 @@ layout: post title: "Installation" img: image-3.png -categories: [one] +categories: ["one", "two"] tags: ["tag_c"] date: 2016-05-09 --- diff --git a/exampleSite/content/posts/no-image.markdown b/exampleSite/content/posts/no-image/index.md index ffbd961..51befdc 100644 --- a/exampleSite/content/posts/no-image.markdown +++ b/exampleSite/content/posts/no-image/index.md @@ -1,7 +1,7 @@ --- layout: post title: "Post with no image" -category: two +categories: ["one", "two"] date: 2016-06-09 --- When there is no image mentioned in the front-matter, default image will be displayed. You can change this image to any other one that suits your needs. diff --git a/static/images/image-2.png b/exampleSite/content/posts/usage/image-2.png Binary files differindex bbb10e5..bbb10e5 100644 --- a/static/images/image-2.png +++ b/exampleSite/content/posts/usage/image-2.png diff --git a/exampleSite/content/posts/usage.markdown b/exampleSite/content/posts/usage/index.md index 83ef94a..d2ee021 100644 --- a/exampleSite/content/posts/usage.markdown +++ b/exampleSite/content/posts/usage/index.md @@ -1,7 +1,7 @@ --- title: "Usage Guide" img: image-2.png -categories: [two] +categories: ["one", "two"] date: "2016-06-12" --- diff --git a/static/images/image-1.png b/exampleSite/content/posts/welcome-to-hugo/image-1.png Binary files differindex 872df82..872df82 100644 --- a/static/images/image-1.png +++ b/exampleSite/content/posts/welcome-to-hugo/image-1.png diff --git a/exampleSite/content/posts/welcome-to-hugo.markdown b/exampleSite/content/posts/welcome-to-hugo/index.md index f61f9c1..e786706 100644 --- a/exampleSite/content/posts/welcome-to-hugo.markdown +++ b/exampleSite/content/posts/welcome-to-hugo/index.md @@ -1,5 +1,5 @@ --- -title: "Welcome to Hugo!" +title: "Welcome to Hugox!" date: 2016-06-13 10:51:47 +0530 img: "image-1.png" categories: [one, two] diff --git a/layouts/_default/list.html b/layouts/_default/list.html index e1cd83d..dde78d5 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -12,7 +12,11 @@ <div class="panel panel-default"> {{ if .Params.img }} - <img width="100%" src="{{ .Site.BaseURL }}images/{{ .Params.img }}" alt="{{ .Title }}"> + {{ with .Resources.Match .Params.img }} + {{ range . }} + <img width="100%" src="{{ .RelPermalink }}" alt="{{ .Title }}"> + {{ end }} + {{ end }} {{ else }} <img width="100%" src="{{ .Site.BaseURL }}images/{{ .Site.Params.defaultImage }}" alt="{{ .Site.Title }}"> {{ end }} |