diff options
author | Nelson/Roberto <dewittn@gmail.com> | 2020-05-12 01:42:24 +0300 |
---|---|---|
committer | Nelson/Roberto <dewittn@gmail.com> | 2020-05-12 01:42:24 +0300 |
commit | 3826f9ca610f3041a484f93947f839c653057b62 (patch) | |
tree | 090b75b2ca35da77bc4acee5e7602afc68abe78f | |
parent | e5ca9f7b35daa8a8981c3493375de203419abec2 (diff) |
- Banner image can now be set in post params or pulled from the bundle.
- Implemented tags
-rw-r--r-- | exampleSite/content/blog/post.10/banner.jpg (renamed from exampleSite/content/blog/post.10/pic04.jpg) | bin | 20737 -> 20737 bytes | |||
-rw-r--r-- | exampleSite/content/blog/post.10/index.md | 4 | ||||
-rw-r--r-- | exampleSite/content/blog/post.3.md | 2 | ||||
-rw-r--r-- | exampleSite/content/blog/post.4.md | 2 | ||||
-rw-r--r-- | layouts/_default/list.html | 4 | ||||
-rw-r--r-- | layouts/_default/single.html | 5 | ||||
-rw-r--r-- | layouts/partials/bannerURL.html | 7 | ||||
-rw-r--r-- | layouts/partials/tags.html | 15 |
8 files changed, 31 insertions, 8 deletions
diff --git a/exampleSite/content/blog/post.10/pic04.jpg b/exampleSite/content/blog/post.10/banner.jpg Binary files differindex b0206cb..b0206cb 100644 --- a/exampleSite/content/blog/post.10/pic04.jpg +++ b/exampleSite/content/blog/post.10/banner.jpg diff --git a/exampleSite/content/blog/post.10/index.md b/exampleSite/content/blog/post.10/index.md index 55fa2eb..3a9ab86 100644 --- a/exampleSite/content/blog/post.10/index.md +++ b/exampleSite/content/blog/post.10/index.md @@ -4,9 +4,7 @@ slug = 'page-bundle-example' date = "2019-08-15T00:00:00" description = 'Donec eget ex magna. Interdum et malesuada fames ac ante ipsum primis in faucibus. Pellentesque venenatis dolor imperdiet dolor mattis sagittis magna etiam.' disqus_identifier = '9' -[[resources]] - name = "header" - src = "pic04.jpg" +tags = ["tag1","tag2"] +++ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam sit amet dui nec dui commodo auctor non eu mauris. Duis varius finibus vestibulum. Praesent aliquam, erat sed dictum feugiat, velit erat iaculis elit, eget iaculis ex libero ac sapien. Sed maximus ut lectus et varius. Nullam posuere velit vitae est consectetur porttitor. Vestibulum tempor felis ante, nec volutpat risus vestibulum ac. Mauris at finibus felis, eu placerat arcu. Sed nec semper nunc. Proin eget mollis felis. Donec fermentum lectus non metus elementum, dignissim ornare felis congue. In rhoncus vehicula nibh, ac imperdiet dolor tincidunt sit amet. diff --git a/exampleSite/content/blog/post.3.md b/exampleSite/content/blog/post.3.md index f0c5012..e3be375 100644 --- a/exampleSite/content/blog/post.3.md +++ b/exampleSite/content/blog/post.3.md @@ -1,7 +1,7 @@ +++ title = 'Augue lorem primis vestibulum' slug = 'post3' -image = 'images/pic07.jpg' +image = 'images/pic02.jpg' date = "2019-04-07T00:00:00" description = 'Donec eget ex magna. Interdum et malesuada fames ac ante ipsum primis in faucibus. Pellentesque venenatis dolor imperdiet dolor mattis sagittis magna etiam.' disableComments = true diff --git a/exampleSite/content/blog/post.4.md b/exampleSite/content/blog/post.4.md index 9101391..d559e48 100644 --- a/exampleSite/content/blog/post.4.md +++ b/exampleSite/content/blog/post.4.md @@ -1,7 +1,7 @@ +++ title = 'Odio magna sed consectetur' slug = 'post4' -image = 'images/pic06.jpg' +image = 'images/pic03.jpg' date = "2019-04-11T00:00:00" description = 'Donec eget ex magna. Interdum et malesuada fames ac ante ipsum primis in faucibus. Pellentesque venenatis dolor imperdiet dolor mattis sagittis magna etiam.' disableComments = true diff --git a/layouts/_default/list.html b/layouts/_default/list.html index ff096a0..ecee70f 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -7,7 +7,9 @@ {{ range .Pages }} <div class="col-6 col-12-narrower"> <section class="box special"> - <span class="image featured"><img src="{{ .Params.image }}" alt="" /></span> + {{ with partial "bannerURL" . }} + <span class="image featured"><img src="{{ . }}" alt="" /></span> + {{ end }} <h3>{{ .Title }}</h3> {{ with .Date }}<p>{{ .Format "Jan 2, 2006" }}</p>{{ end }} {{ with .Description }} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 0b95cb4..d8119a1 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -4,10 +4,11 @@ <p>{{ .Date.Format "Jan 2, 2006" }}</p> </header> <div class="box"> - {{ with .Params.image }} - <span class="image featured"><img src="{{ . | relURL }}" alt="" /></span> + {{ with partial "bannerURL" . }} + <span class="image featured"><img src="{{ . }}" alt="" /></span> {{ end }} {{ .Content }} + {{ partial "tags" . }} </div> {{ if .Site.DisqusShortname }} <div class="box"> diff --git a/layouts/partials/bannerURL.html b/layouts/partials/bannerURL.html new file mode 100644 index 0000000..4f2abfa --- /dev/null +++ b/layouts/partials/bannerURL.html @@ -0,0 +1,7 @@ +{{ $bannerURL := "" }} +{{ if .Params.image }} + {{ $bannerURL = (.Params.image | relURL) }} +{{ else if .Resources.GetMatch "banner.jpg" }} + {{ $bannerURL = (.Resources.GetMatch "banner.jpg").Permalink }} +{{ end }} +{{ return $bannerURL }}
\ No newline at end of file diff --git a/layouts/partials/tags.html b/layouts/partials/tags.html new file mode 100644 index 0000000..abc2c4d --- /dev/null +++ b/layouts/partials/tags.html @@ -0,0 +1,15 @@ +{{/* Code thanks to Jake Wiesler, https://www.jakewiesler.com/blog/hugo-taxonomies/ */}} +{{ $taxonomy := "tags" }} +{{ with .Param $taxonomy }} + <hr /> + <h3>{{ $taxonomy }}</h3> + <ul> + {{ range $index, $tag := . }} + {{ with $.Site.GetPage (printf "/%s/%s" $taxonomy $tag) -}} + <li> + <a href="{{ .Permalink }}">{{ $tag | urlize }}</a> + </li> + {{- end -}} + {{- end -}} + </ul> +{{ end }}
\ No newline at end of file |