| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- <!-- Topics 區塊 -->
- <div class="d-flex align-items-center position-relative tab-category mt-5 pt-5 pb-3">
- <section class="w-100">
- <h3 class="post-block-title">
- <span>Topics</span>
- </h3>
- </section>
- <!-- 收集所有 categories,並帶上文章數量 -->
- {{ $cats := slice }}
- {{ range $name, $taxonomy := site.Taxonomies.categories }}
- {{ $cats = $cats | append (dict
- "name" $name
- "count" (len $taxonomy.Pages)
- "page" $taxonomy.Page
- ) }}
- {{ end }}
- <!-- 依照 count 由多到少排序(熱門分類優先) -->
- {{ $cats = sort $cats "count" "desc" }}
- <ul class="nav nav-pills mb-3 ps-3 position-absolute" id="pills-tab" role="tablist"
- style="right: 0; background: #fff;">
- {{ range $index, $cat := first 5 $cats }}
- {{ $page := index $cat "page" }}
- <li class="nav-item" role="presentation">
- <button class="nav-link {{ if eq $index 0 }}active{{ end }}" id="pills-home-tab-{{$index}}" data-bs-toggle="pill"
- data-bs-target="#pills-home-{{$index}}" type="button" role="tab" aria-controls="pills-home-{{$index}}"
- aria-selected="{{ if eq $index 0 }}true{{ else }}false{{ end }}">
- {{ $page.LinkTitle }}
- </button>
- </li>
- {{ end }}
- </ul>
- </div>
- <!-- 對應的 tab content -->
- <div class="tab-content" id="pills-tabContent">
- {{ range $index, $cat := first 5 $cats }}
- {{ $catName := index $cat "name" }}
- <div class="tab-pane fade show {{ if eq $index 0 }}active{{ end }}" id="pills-home-{{$index}}" role="tabpanel"
- aria-labelledby="pills-home-tab-{{$index}}">
- <div class="row">
- {{/* 取出這個 category 底下的文章 */}}
- {{ $t := slice $catName }}
- {{ range $i, $post := where site.RegularPages ".Params.categories" "intersect" $t }}
- {{/* 第 0、1 則:大圖卡片 */}}
- {{ if or (eq $i 0) (eq $i 1) }}
- <div class="col-12 col-lg-6 mt-3">
- <div class="bg-img" style="background-image: linear-gradient(
- to bottom,
- rgba(0,0,0, 0) 50%,
- rgba(0,0,0, 100)
- ),
- url('{{ $post.Params.image | relURL }}');" onclick="location.href='{{ $post.Permalink }}'">
- <section>
- {{ range ($post.GetTerms "categories") }}
- <a href="{{ .Permalink }}">{{ .LinkTitle }}</a>
- {{ end }}
- <small>{{ $post.Date | time.Format ":date_long" }}</small>
- <h2 class="post-title">
- <a href="{{ $post.Permalink }}">{{ $post.Params.title }}</a>
- </h2>
- </section>
- </div>
- </div>
- {{/* 第 2~5 則:右側小圖列表 */}}
- {{ else if or (eq $i 2) (eq $i 3) (eq $i 4) (eq $i 5) }}
- <div class="col-12 col-lg-6 mt-3">
- <div class="row">
- <div class="col-5">
- <a href="{{ $post.Permalink }}">
- <img src="{{ $post.Params.image | relURL }}" alt="" class="news-thumbnail">
- </a>
- </div>
- <div class="col-7 border-bottom">
- <section class="news-info">
- {{ range ($post.GetTerms "categories") }}
- <a href="{{ .Permalink }}">{{ .LinkTitle }}</a>
- {{ end }}
- <small>{{ $post.Date | time.Format ":date_long" }}</small>
- </section>
- <h2 class="post-title">
- <a href="{{ $post.Permalink }}">{{ $post.Params.title }}</a>
- </h2>
- <!--
- <p class="post-depiction">
- <a href="{{ $post.Permalink }}">{{ $post.Summary }}</a>
- </p>
- -->
- </div>
- </div>
- </div>
- {{ end }}
- {{ end }} {{/* range posts in this category */}}
- </div>
- </div>
- {{ end }} {{/* range $cats for tab panes */}}
- </div>
- <!-- {{ $p := slice }}
- {{ range site.Taxonomies.categories }}
- {{ $p = $p | append .Page }}
- {{ end }}
- <div class="d-flex align-items-center position-relative tab-category mt-5 pt-5 pb-3">
- <section class="w-100">
- <h3 class="post-block-title">
- <span>Topics</span>
- </h3>
- </section>
- {{ $p := slice }}
- {{ range site.Taxonomies.categories }}
- {{ $p = $p | append .Page }}
- {{ end }}
- <ul class="nav nav-pills mb-3 ps-3 position-absolute" id="pills-tab" role="tablist"
- style="right: 0; background: #fff;">
- {{ range $index, $element := first 5 $p }}
- <li class="nav-item" role="presentation">
- <button class="nav-link {{ if (eq $index 0) }}active{{ end }}" id="pills-home-tab-{{$index}}"
- data-bs-toggle="pill" data-bs-target="#pills-home-{{$index}}" type="button" role="tab"
- aria-controls="pills-home-{{$index}}" aria-selected="true">{{ .LinkTitle }}</button>
- </li>
- {{ end }}
- </ul>
- </div>
- <div class="tab-content" id="pills-tabContent">
- {{ range $index, $element := first 6 $p }}
- <div class="tab-pane fade show {{ if (eq $index 0) }}active{{ end }}" id="pills-home-{{$index}}" role="tabpanel"
- aria-labelledby="pills-home-tab">
- <div class="row">
- {{ $t := slice .LinkTitle }}
- {{ range $index, $element := where .Site.Pages ".Params.categories" "intersect" $t }}
- {{ if or (eq $index 0) (eq $index 1) }}
- <div class="col-12 col-lg-6 mt-3">
- <div class="bg-img"
- style="background-image: linear-gradient(to bottom,rgba(0,0,0, 0) 50%, rgba(0,0,0, 100)),url('{{ .Params.image | relURL }}');"
- onclick="location.href='{{ .Permalink }}'">
- <section>
- {{ range (.GetTerms "categories") }}
- <a href="{{ .Permalink }}">{{ .LinkTitle }}</a>
- {{ end }}
- <small>{{ .Date | time.Format ":date_long" }}</small>
- <h2 class="post-title">
- <a href="{{ .Permalink }}">{{ .Params.title }}</a>
- </h2>
- </section>
- </div>
- </div>
- {{ else if or (eq $index 2) (eq $index 3) (eq $index 4) (eq $index 5) }}
- <div class="col-12 col-lg-6 mt-3">
- <div class="row">
- <div class="col-5">
- <a href="{{ .Permalink }}">
- <img src="{{ .Params.image | relURL }}" alt="" class="news-thumbnail">
- </a>
- </div>
- <div class="col-7 border-bottom">
- <section class="news-info">
- {{ range (.GetTerms "categories") }}
- <a href="{{ .Permalink }}">{{ .LinkTitle }}</a>
- {{ end }}
- <small>{{ .Date | time.Format ":date_long" }}</small>
- </section>
- <h2 class="post-title">
- <a href="{{ .Permalink }}">{{ .Params.title }}</a>
- </h2>
- </div>
- </div>
- </div>
- {{ end }}
- {{ end }}
- </div>
- </div>
- {{ end }}
- </div> -->
|