default.html 4.1 KB
Newer Older
Miykael_xxm's avatar
init  
Miykael_xxm 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
{{ "<!-- details page -->" | safeHTML }}
<section class="single section-sm pb-0">
  <div class="container">
    <div class="row">
      <div class="col-lg-3">
        <div class="sidebar">
          <ul class="list-styled">
            {{ $currentNode := . }}
            <a class="back-btn" href="{{ .Site.BaseURL | relLangURL }}"></a>
            {{range .Site.Home.Sections.ByWeight}}
              {{ if eq .FirstSection $currentNode.FirstSection }}
              {{ template "section-tree-nav" dict "sect" . "currentnode" $currentNode}}
              {{ end }}
            {{ end }}
          </ul>
        </div>
      </div>
      <div class="col-lg-9">
        <div class="p-lg-5 p-4 bg-white">
          <h2 class="mb-5">{{ .Title }}</h2>
          {{ if .Content }}
          <div class="content">{{.Content}}</div>
          {{ else }}
          <div class="bg-light p-4">
            <ul class="page-list">
              {{ template "section-tree-nav" dict "sect" . "currentnode" $currentNode }}
            </ul>
          </div>
          {{ end }}
Miykael_xxm's avatar
update  
Miykael_xxm 已提交
30
          <p class="post-meta border-bottom pb-3 mb-0 mt-3">更新于 {{ .Lastmod.Format "2006-01-02" }}</p>
Miykael_xxm's avatar
init  
Miykael_xxm 已提交
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
          <nav class="pagination mt-3">
            <!-- Next prev page -->
            {{ $currentNode := . }}
            {{ template "menu-nextprev" dict "menu" .Site.Home "currentnode" $currentNode }}
            {{ define "menu-nextprev" }}
            {{$currentNode := .currentnode }}
            {{ if ne .menu.Params.hidden true}}
            {{if hasPrefix $currentNode.Permalink .menu.Permalink }}
            {{ $currentNode.Scratch.Set "NextPageOK" "OK" }}
            {{ $currentNode.Scratch.Set "prevPage" ($currentNode.Scratch.Get "prevPageTmp") }}
            {{else}}
            {{if eq ($currentNode.Scratch.Get "NextPageOK") "OK"}}
            {{ $currentNode.Scratch.Set "NextPageOK" nil }}
            {{ $currentNode.Scratch.Set "nextPage" .menu }}
            {{end}}
            {{end}}
            {{ $currentNode.Scratch.Set "prevPageTmp" .menu }}

            {{ $currentNode.Scratch.Set "pages" .menu.Pages }}
            {{ if .menu.IsHome}}
            {{ $currentNode.Scratch.Set "pages" .menu.Sections }}
            {{ else if .menu.Sections}}
            {{ $currentNode.Scratch.Set "pages" (.menu.Pages | union .menu.Sections) }}
            {{end}}
            {{ $pages := ($currentNode.Scratch.Get "pages") }}

            {{ range $pages.ByWeight  }}
            {{ template "menu-nextprev" dict "menu" . "currentnode" $currentNode }}
            {{end}}
            {{ end }}
            {{ end }}

            {{with ($.Scratch.Get "prevPage")}}
            <a class="nav nav-prev" href="{{.Permalink }}"><i class="ti-arrow-left mr-2"></i> <span class="d-none d-md-block">{{.Title}}</span></a>
            {{end}}
            {{with ($.Scratch.Get "nextPage")}}
            <a class="nav nav-next" href="{{.Permalink }}"> <span class="d-none d-md-block">{{.Title}}</span><i class="ti-arrow-right ml-2"></i></a>
            {{end}}
          </nav>
        </div>
      </div>
    </div>
  </div>
</section>
{{ "<!-- /details page -->" | safeHTML }}

<!-- templates -->
{{ define "section-tree-nav" }}
{{ $showvisitedlinks := .showvisitedlinks }}
{{ $currentNode := .currentnode }}
{{with .sect}}
{{safeHTML .Params.head}}
{{ $fileUniqueID := "" }}
{{ with .File }}{{ $fileUniqueID = .UniqueID }}{{ end }}
{{ $currentNodeFileUniqueID := "" }}
{{ with $currentNode.File }}{{ $currentNodeFileUniqueID = .UniqueID }}{{ end }}
<li data-nav-id="{{.Permalink}}" title="{{.Title}}" class="sidelist
  {{if eq $fileUniqueID $currentNodeFileUniqueID}}active{{end}}">
  <a href="{{.Permalink}}">
    {{safeHTML .Params.Pre}}{{or .Params.menuTitle .LinkTitle .Title}}{{safeHTML .Params.Post}}
  </a>
  {{ $numberOfPages := (add (len .Pages) (len .Sections)) }}
  {{ if ne $numberOfPages 0 }}
    <ul>
      {{ range .Pages.ByWeight }}
        {{ if and .Params.hidden (not $.showhidden) }}
        {{else}}
          {{ template "section-tree-nav" dict "sect" . "currentnode" $currentNode }}
        {{end}}
      {{end}}
    </ul>
  {{ end }}
</li>
{{ end }}
{{ end }}