<!DOCTYPE html>
<html lang="en">
{{ partial "head_single.html" . }}
<!-- <head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge, Chrome=1">
  <meta http-equiv="Cache-Control" content="no-cache">
  <title>ChoozMo AI-PR Service</title>
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
    integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
  <link rel="stylesheet" href="//use.fontawesome.com/releases/v5.11.2/css/all.css">
  <link rel="stylesheet" href="/css/style.css">
  <link rel="stylesheet" href="/css/custom.css">
</head> -->

<body>
  {{ partial "navbar.html" . }}

  <main class="container news-content" style="overflow-x: hidden;">
    <ul id="categories">
      <li>
        <button id="all">
          <a href="/main-news/">所有訊息</a>
        </button>
      </li>
      <li>
        <button id="focus">
          <a href="/main-news/focus/">焦點訊息</a>
        </button>
      </li>
      <li>
        <button id="serve">
          <a href="/main-news/serve/">最新服務</a>
        </button>
      </li>
      <li>
        <button id="event">
          <a href="/main-news/event/">活動公告</a>
        </button>
      </li>
    </ul>

    {{ if eq (relURL .URL) ("/main-news/focus/") }}
    {{ $t := $.Site.GetPage "/main-news" }}
    <ul class="list">
      {{ range $index, $element := where $t.Pages "Params.categories" "焦點訊息" }}
      {{ $t := $.Site.GetPage "/main-news" }}
      <li>
        <a href="{{ .RelPermalink }}">
          <h2>{{ .Title }}</h2>
        </a>
        <hr>
        <section class="d-flex justify-content-between">
          <p class="news-category">{{ .Params.categories }}</p>
          <p>{{ .PublishDate.Format "2006-01-02" }}</p>
        </section>
        <a href="{{ .RelPermalink }}" class="content">
          <p>{{.Summary}}</p>
        </a>
        <div class="more-btn">
          <a href="{{ .RelPermalink }}">
            閱讀文章
          </a>
        </div>
      </li>
      {{ end }}
    </ul>
    {{ end }}

    {{ if eq (relURL .URL) ("/main-news/serve/") }}
    {{ $t := $.Site.GetPage "/main-news" }}
    <ul class="list">
      {{ range $index, $element := where $t.Pages "Params.categories" "最新服務" }}
      {{ $t := $.Site.GetPage "/main-news" }}
      <li>
        <a href="{{ .RelPermalink }}">
          <h2>{{ .Title }}</h2>
        </a>
        <hr>
        <section class="d-flex justify-content-between">
          <p class="news-category">{{ .Params.categories }}</p>
          <p>{{ .PublishDate.Format "2006-01-02" }}</p>
        </section>
        <a href="{{ .RelPermalink }}" class="content">
          <p>{{.Summary}}</p>
        </a>
        <div class="more-btn">
          <a href="{{ .RelPermalink }}">
            閱讀文章
          </a>
        </div>
      </li>
      {{ end }}
    </ul>
    {{ end }}

    {{ if eq (relURL .URL) ("/main-news/event/") }}
    {{ $t := $.Site.GetPage "/main-news" }}
    <ul class="list">
      {{ range $index, $element := where $t.Pages "Params.categories" "活動公告" }}
      {{ $t := $.Site.GetPage "/main-news" }}
      <li>
        <a href="{{ .RelPermalink }}">
          <h2>{{ .Title }}</h2>
        </a>
        <hr>
        <section class="d-flex justify-content-between">
          <p class="news-category">{{ .Params.categories }}</p>
          <p>{{ .PublishDate.Format "2006-01-02" }}</p>
        </section>
        <a href="{{ .RelPermalink }}" class="content">
          <p>{{.Summary}}</p>
        </a>
        <div class="more-btn">
          <a href="{{ .RelPermalink }}">
            閱讀文章
          </a>
        </div>
      </li>
      {{ end }}
    </ul>
    {{ end }}

    {{ $paginator := .Paginate .Data.Pages }}
    <ul class="list">
      {{ range $paginator.Pages }}
      {{ $t := $.Site.GetPage "/main-news" }}
      {{ if ne .Params.categories "url" }} <!-- 排除分類用的 content -->
      <li>
        <a href="{{ .RelPermalink }}">
          <h2>{{ .Title }}</h2>
        </a>
        <hr>
        <section class="d-flex justify-content-between">
          <p class="news-category">{{ .Params.categories }}</p>
          <p>{{ .PublishDate.Format "2006-01-02" }}</p>
        </section>
        <a href="{{ .RelPermalink }}" class="content">
          <p>{{.Summary}}</p>
        </a>
        <div class="more-btn">
          <a href="{{ .RelPermalink }}">
            閱讀文章
          </a>
        </div>
      </li>
      {{ end }}
      {{ end }}
    </ul>
  </main>

  {{ partial "footer.html" . }}

  <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.2/dist/umd/popper.min.js"
    integrity="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p"
    crossorigin="anonymous"></script>
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.min.js"
    integrity="sha384-cVKIPhGWiC2Al4u+LWgxfKTRIcfu0JTxR+EQDz/bgldoEyl4H0zUF0QKbrJ0EcQF"
    crossorigin="anonymous"></script>
  <script src="//code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="
    crossorigin="anonymous"></script>

  <script>
    let pathname = window.location.pathname;
    $('.news-content button').removeClass('active');
    if (pathname.includes('focus')) {
      $('.news-content #focus').addClass('active');
    } else if (pathname.includes('serve')) {
      $('.news-content #serve').addClass('active');
    } else if (pathname.includes('event')) {
      $('.news-content #event').addClass('active');
    } else {
      $('.news-content #all').addClass('active');
    }
  </script>
</body>

</html>