【发布时间】:2021-10-08 10:48:22
【问题描述】:
更新
参考 Oleg Butuzov 回答我可以解决我的第一个问题:
{{ $paginator := .Paginate (where .Site.RegularPages ".Params.yt" ">" "") 1 }}
但我有一个新问题,它列出了内容文件夹 Hugo 上包含参数“yt”的所有帖子,然后我从 @bep 回复的官方 Hugo Discusion https://discourse.gohugo.io/t/complex-where-filter-using-and-or-not/5758/3 解决了我的问题。
这里..如何用两个条件过滤 HUGO:
{{ $paginator := .Paginate (where (where .Site.RegularPages ".Params.yt" ">" "") ".Params.type" "post") 1 }}
我更新并清除了这个问题,因为它真的很难找到关于这个雨果问题,我希望它也能解决你的问题.. thx :)
======= 原始问题 ======
如何过滤变量 $Paginator 的“where”以仅列出包含自定义参数“yt”的帖子?
{{ $paginator := .Paginate (where .Site.RegularPages "Type" "post") 2 }}
{{ range $paginator.Pages }}
{{ .Params.yt }}
{{ end }}
{{ template "_internal/pagination.html" . }}
我的 Hugo 模板结构:
内容/发布/ ---- post1.md ---- post2.md
主题/布局/post/gameplay.html
然后
post1.md
---
Title: Title 1
type: post
yt: ytchannelid
---
post2.md
---
Title: Tile 2
type: post
---
thanks before :)
【问题讨论】:
标签: go templates pagination blogs hugo