mirror of
https://github.com/tiennm99/hugoDocs.git
synced 2026-10-14 02:16:09 +00:00
Always show the latest showcase item on front page
This commit is contained in:
1 file changed
+28
-21
@@ -4,26 +4,10 @@
|
|||||||
<div class="w-100">
|
<div class="w-100">
|
||||||
<div class="w-100 overflow-x-scroll">
|
<div class="w-100 overflow-x-scroll">
|
||||||
<div class="row nowrap mv2 pb1">
|
<div class="row nowrap mv2 pb1">
|
||||||
{{ range $p := first 10 (where .Site.RegularPages "Section" "showcase" | shuffle) }}
|
{{ $showcasePages := where .Site.RegularPages "Section" "showcase" }}
|
||||||
{{ $img := (.Resources.ByType "image").GetMatch "*featured*" }}
|
{{ template "home_showcase_item" (index $showcasePages 0) }}
|
||||||
{{ with $img }}
|
{{ range $p := first 10 ($showcasePages | after 1 | shuffle) }}
|
||||||
{{ $big := .Fill "1024x512 top" }}
|
{{template "home_showcase_item" $p }}
|
||||||
{{ $small := $big.Resize "512x" }}
|
|
||||||
<a href="{{ $p.RelPermalink}}" class="tile lazyload cover dib f4 h5 ml1 mr4 bg-black relative mw-100 shadow-5" style="width:{{ $small.Width }}px;"
|
|
||||||
data-bg="{{ $img.RelPermalink }}"
|
|
||||||
data-sizes="auto"
|
|
||||||
data-srcset="{{ $small.RelPermalink }} 1x,
|
|
||||||
{{ $big.RelPermalink }} 2x" data-src="small"
|
|
||||||
>
|
|
||||||
{{with $p.Title}}
|
|
||||||
<div class="details absolute bottom-0 f3-ns f4 left-0 o-0 right-0 top-0">
|
|
||||||
<div class="absolute bottom-0 pa2 tc white">
|
|
||||||
{{.}} →
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{end}}
|
|
||||||
</a>
|
|
||||||
{{ end }}
|
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -32,4 +16,27 @@
|
|||||||
<div class="flex w-100 mt4 justify-end">{{/* using Flex to make the button show up on the right side */}}
|
<div class="flex w-100 mt4 justify-end">{{/* using Flex to make the button show up on the right side */}}
|
||||||
<a href="/showcase/" class="br2 f6 bg-primary-color-dark hover-bg-primary-color link ph3 pv2 ttu white">See All</a>
|
<a href="/showcase/" class="br2 f6 bg-primary-color-dark hover-bg-primary-color link ph3 pv2 ttu white">See All</a>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
||||||
|
{{ define "home_showcase_item" }}
|
||||||
|
{{ $img := (.Resources.ByType "image").GetMatch "*featured*" }}
|
||||||
|
{{ with $img }}
|
||||||
|
{{ $big := .Fill "1024x512 top" }}
|
||||||
|
{{ $small := $big.Resize "512x" }}
|
||||||
|
<a href="{{ $.RelPermalink}}" class="tile lazyload cover dib f4 h5 ml1 mr4 bg-black relative mw-100 shadow-5" style="width:{{ $small.Width }}px;"
|
||||||
|
data-bg="{{ $img.RelPermalink }}"
|
||||||
|
data-sizes="auto"
|
||||||
|
data-srcset="{{ $small.RelPermalink }} 1x,
|
||||||
|
{{ $big.RelPermalink }} 2x" data-src="small"
|
||||||
|
>
|
||||||
|
{{with $.Title}}
|
||||||
|
<div class="details absolute bottom-0 f3-ns f4 left-0 o-0 right-0 top-0">
|
||||||
|
<div class="absolute bottom-0 pa2 tc white">
|
||||||
|
{{.}} →
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{end}}
|
||||||
|
</a>
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
Reference in new issue
Block a user