news-tab.html 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. </section>
  47. </div>
  48. </div>
  49. {{ else if or (eq $index 2) (eq $index 3) (eq $index 4) (eq $index 5) }}
  50. <div class="col-12 col-lg-6 mt-3">
  51. <div class="row">
  52. <div class="col-5">
  53. <a href="{{ .Permalink }}">
  54. <img src="{{ .Params.image | relURL }}" alt="" class="news-thumbnail">
  55. </a>
  56. </div>
  57. <div class="col-7 border-bottom">
  58. <section class="news-info">
  59. {{ range (.GetTerms "categories") }}
  60. <a href="{{ .Permalink }}">{{ .LinkTitle }}</a>
  61. {{ end }}
  62. <small>{{ .Date | time.Format ":date_long" }}</small>
  63. </section>
  64. <h2 class="post-title">
  65. <a href="{{ .Permalink }}">{{ .Params.title }}</a>
  66. </h2>
  67. <p class="post-depiction">
  68. <a href="{{ .Permalink }}">{{ .Summary }}</a>
  69. </p>
  70. </div>
  71. </div>
  72. </div>
  73. {{ end }}
  74. {{ end }}
  75. </div>
  76. </div>
  77. {{ end }}
  78. </div>