8

我的结构content

content
|-post
| |-00.md
| |-01.md
| |-02.md
|-about.md

在帖子的单个模板中,我想要一个页脚:

  • 是指向下一篇文章的链接,或者,如果没有下一篇文章可用
  • 是文本“待续”。

在伪模板代码中,这意味着:

{{ if nextpost.exists }} #. becomes nexpost here
  <a href="{{ .Permalink }}">{{ .Title }}</a>
{{ end }}

当前nextpost位置+1


如何创建这种链接?

4

1 回答 1

15

听起来您想要.NextInSection变量。如果你使用with函数,你可以让它像你想要的那样工作。

{{ with .NextInSection }}
  <a href="{{ .Permalink }}">{{ .Title }}</a>
{{ end }}

您也可以.PrevInSection以类似的方式使用。

于 2017-05-30T23:26:00.233 回答