2017-05-25 45 views
1

我在content結構:(HUGO) - 鏈接到下一個職位

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

在爲我想有一個頁腳的職位單模板:

  • 是一個鏈接到下一篇文章,或者如果沒有下一篇文章可用
  • 是文本「待續」。

僞模板的代碼,這意味着:

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

nextpost是currentpost + 1


如何創建怎樣的聯繫?

回答

1

這聽起來像你想.NextInSection變量。如果您使用with功能,則可以使其按照您的要求工作。

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

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

相關問題