链接到下一篇文章

Asq*_*iir 5 hugo

我的结构在content

content
|-post
| |-00.md
| |-01.md
| |-02.md
|-about.md
Run Code Online (Sandbox Code Playgroud)

在帖子的单个模板中,我希望有一个页脚:

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

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

{{ if nextpost.exists }} #. becomes nexpost here
  <a href="{{ .Permalink }}">{{ .Title }}</a>
{{ end }}
Run Code Online (Sandbox Code Playgroud)

nextpostcurrentpost + 1 在哪里


如何创建这种链接?

Jac*_*lor 13

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

{{ with .NextInSection }}
  <a href="{{ .Permalink }}">{{ .Title }}</a>
{{ end }}
Run Code Online (Sandbox Code Playgroud)

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