news-tab.html 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. {{ $p := slice }}
  2. {{ range site.Taxonomies.categories }}
  3. {{ $p = $p | append .Page }}
  4. {{ end }}
  5. <div class="d-flex align-items-center position-relative tab-category mt-5 pt-5 pb-3">
  6. <section class="w-100">
  7. <h3 class="post-block-title">
  8. <span>推薦主題</span>
  9. </h3>
  10. </section>
  11. {{ $p := slice }}
  12. {{ range site.Taxonomies.categories }}
  13. {{ $p = $p | append .Page }}
  14. {{ end }}
  15. <ul class="nav nav-pills mb-3 ps-3 position-absolute" id="pills-tab" role="tablist"
  16. style="right: 0; background: #fff;">
  17. {{ range $index, $element := first 5 $p }}
  18. <li class="nav-item" role="presentation">
  19. <button class="nav-link {{ if (eq $index 0) }}active{{ end }}" id="pills-home-tab-{{$index}}"
  20. data-bs-toggle="pill" data-bs-target="#pills-home-{{$index}}" type="button" role="tab"
  21. aria-controls="pills-home-{{$index}}" aria-selected="true">{{ .LinkTitle }}</button>
  22. </li>
  23. {{ end }}
  24. </ul>
  25. </div>
  26. <div class="tab-content" id="pills-tabContent">
  27. {{ range $index, $element := first 6 $p }}
  28. <div class="tab-pane fade show {{ if (eq $index 0) }}active{{ end }}" id="pills-home-{{$index}}" role="tabpanel"
  29. aria-labelledby="pills-home-tab">
  30. <div class="row">
  31. {{ $t := slice .LinkTitle }}
  32. {{ range $index, $element := where .Site.Pages ".Params.categories" "intersect" $t }}
  33. {{ if or (eq $index 0) (eq $index 1) }}
  34. <div class="col-12 col-lg-6 mt-3">
  35. <div class="bg-img"
  36. style="background-image: linear-gradient(to bottom,rgba(0,0,0, 0) 50%, rgba(0,0,0, 100)),url('{{ .Params.image | relURL }}');"
  37. onclick="location.href='{{ .Permalink }}'">
  38. <section>
  39. {{ range (.GetTerms "categories") }}
  40. <a href="{{ .Permalink }}">{{ .LinkTitle }}</a>
  41. {{ end }}
  42. <small>{{ .Date | time.Format ":date_long" }}</small>
  43. <h2 class="post-title">
  44. <a href="{{ .Permalink }}">{{ .Params.title }}</a>
  45. </h2>
  46. <p class="post-depiction">
  47. <a href="{{ .Params.url }}" style="color:#fff;">{{ .Summary }}</a>
  48. </p>
  49. </section>
  50. </div>
  51. </div>
  52. {{ else if or (eq $index 2) (eq $index 3) (eq $index 4) (eq $index 5) }}
  53. <div class="col-12 col-lg-6 mt-3">
  54. <div class="row">
  55. <div class="col-5">
  56. <a href="{{ .Permalink }}">
  57. <img src="{{ .Params.image | relURL }}" alt="" class="news-thumbnail">
  58. </a>
  59. </div>
  60. <div class="col-7 border-bottom">
  61. <section class="news-info">
  62. {{ range (.GetTerms "categories") }}
  63. <a href="{{ .Permalink }}">{{ .LinkTitle }}</a>
  64. {{ end }}
  65. <small>{{ .Date | time.Format ":date_long" }}</small>
  66. </section>
  67. <h2 class="post-title">
  68. <a href="{{ .Permalink }}">{{ .Params.title }}</a>
  69. </h2>
  70. <p class="post-depiction">
  71. <a href="{{ .Permalink }}">{{ .Summary }}</a>
  72. </p>
  73. </div>
  74. </div>
  75. </div>
  76. {{ end }}
  77. {{ end }}
  78. </div>
  79. </div>
  80. {{ end }}
  81. </div>