2017-12-20 2 views
0

これは簡単な質問ですが、私はすでに多くの時間を費やしており、決定的な答えは見つかりません。ここに私のブログの現在の状態は次のとおりです。https://brucou.github.io/ProjectsHugo:セクションページにサブセクションのリストを表示する方法

、私は、次のディレクトリ構造を持っている:私のプロジェクトページ(/projects/)で

Projects 
    Component combinators 
    Trees and forests 
    Circuitry 

、私は、対応するサブの一覧を表示したいですフォルダ、すなわちComponent combinatorsTrees and forestsなど、対応するパーマリンク。

私はつまり、例えば、プロジェクトページ、ディレクトリツリー、現在、このコードが表示さ/layouts/projects/list.html

<ul> 
    {{ template "section-tree-nav" .Site.Home }} 
</ul> 
{{ define "section-tree-nav" }} 
    {{ range .Sections}} 
    <li>{{ .Title }} 
     <ul> 
      {{ range .Pages }} 
      <li><a href="{{ .RelPermalink}}">{{ .Title }}</a></li> 
      {{ end }} 
      <ul> 
       {{ template "section-tree-nav" . }} 
      </ul> 
     </ul> 
    </li> 
    {{ end }} 
{{ end }} 

でこのコードを持っている:私の質問がある

Posts 
    Reactive programming : a component-based approach 
    A componentization model for cyclejs 
    Componentization against complexity 
    User interfaces as reactive systems 
Projects 
    Component combinators 

  • Projectsディレクトリのコンテンツのみを表示する方法はありますか?または基本的にどのようにタイトルのコンテンツにifを行うには?プロジェクトディレクトリの?私は、これはプロジェクトページに表示したいされ

:階層のレベルで

{{ partial "header" . }} 

<article> 
    <header> 
     {{ partial "title" . }} 
     {{ with .Content }}{{.}}{{ end }} 
    </header> 

    {{ if (eq $.Parent.Title "Projects") }} 
     <ul class="no-bullet"> 
      {{ range .Paginator.Pages }} 
      {{ partial "li" . }} 
      {{ end }} 
     </ul> 
     {{ partial "paginator" . }} 
    {{ else }} 
     {{ range (where .Site.Pages "Section" "projects") }} 
     <ul class="no-bullet"> 
      {{ range .Sections }} 
      <li> 
       <span><time datetime="{{.Date}}">{{ .Date.Format .Site.Params.DateFmt }}</time></span> 
       <a href="{{ .Permalink }}">{{ .Title }}</a> 
      </li> 
      {{ end }} 
     </ul> 
     {{ end }} 
    {{ end }} 

</article> 
{{ partial "footer" . }} 


{{/* keep the/right next to the parenthesis */}} 
{{/* printf "%#v" $.CurrentSection.Title */}} 
{{/* printf "%#v" (eq $.Parent.Title "Projects") */}} 

基本的に、我々の枝:

Component combinators 
    Trees and forests 

答えて

0

は、このようにそれを解決しました。トップレベルにある場合は、ディレクトリ(.Sectionsに格納されています)を表示します。そうでない場合は、ページを表示します。

関連する問題