mirror of
https://github.com/CaiJimmy/hugo-theme-stack.git
synced 2024-11-23 10:21:46 +01:00
feat(widget/archive): add config to limit output number
This commit is contained in:
parent
98c819b858
commit
ff351ab294
2 changed files with 13 additions and 1 deletions
|
@ -17,6 +17,8 @@ title = "Example Site"
|
|||
favicon = ""
|
||||
[params.widgets]
|
||||
enabled = ['archive', 'tag-cloud']
|
||||
[params.widgets.archive]
|
||||
limit = 5
|
||||
[params.widgets.tagCloud]
|
||||
limit = 10
|
||||
[params.opengraph]
|
||||
|
|
|
@ -7,7 +7,9 @@
|
|||
{{ $v1 := where .Site.RegularPages "Section" "post" }}
|
||||
{{ $v2 := where .Site.RegularPages "Params.hidden" "!=" true }}
|
||||
{{ $filtered := $v1 | intersect $v2 }}
|
||||
{{ range $filtered.GroupByDate "2006" }}
|
||||
{{ $archive := $filtered.GroupByDate "2006" }}
|
||||
|
||||
{{ range first .Site.Params.widgets.archive.limit ($archive) }}
|
||||
{{ $id := lower (replace .Key " " "-") }}
|
||||
<div class="archive-year">
|
||||
<a href="{{ $.Site.BaseURL }}/archive#{{ $id }}">
|
||||
|
@ -16,4 +18,12 @@
|
|||
</a>
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
{{ if gt (len $archive) .Site.Params.widgets.archive.limit }}
|
||||
<div class="archive-year">
|
||||
<a href="{{ $.Site.BaseURL }}/archive">
|
||||
<span class="year">More</span>
|
||||
</a>
|
||||
</div>
|
||||
{{ end }}
|
||||
</section>
|
||||
|
|
Loading…
Reference in a new issue