2019-10-21 / syui

hugo

hugoでちょっとハマったところ

content/post以下の記事一覧を表示したいけど、content/post/_index.htmlのリンクは表示したくない.mainSectionsのと、古い順.Reverseに表示したい場合。

{{ range first 100 (where site.RegularPages.Reverse "Type" "in" site.Params.mainSections) }}

なんか、次の記事へのリンクが.Paginateとか.Paginator.HasPrevで取得できず、エラーがgolangのバグっぽかったので、.PrevInSection .NextInSectionを使った。

{{ if or .PrevInSection .NextInSection }}
<nav id="article-nav">
    {{ if .PrevInSection }}
    <a href="{{ .PrevInSection.Permalink }}" id="article-nav-older" class="article-nav-link-wrap">
<i class="{{ $next }}"></i> {{ .PrevInSection.Title }}
    </a>
    {{ end }}
    {{ if .NextInSection }}
    <a href="{{ .NextInSection.Permalink }}" id="article-nav-newer" class="article-nav-link-wrap">
      <i class="{{ $next }}"></i> {{ .NextInSection.Title }}
    </a>
    {{ end }}
</nav>
{{ end }}