{{ $num_recent_posts := default 7 .Site.Params.sidebar.num_recent_posts }}
{{ $posts := first $num_recent_posts (where .Site.RegularPages "Section" "in" .Site.Params.mainSections) }}
{{ if gt (len $posts) 0 }}
<section class="recent-content">
  <h3 class="post-block-title">
    <span>最新消息</span>
  </h3>
  <ol class="list-unstyled news-list">
    {{ range $posts }}
    <li class="d-flex align-items-center">
      <a href="{{.RelPermalink}}">
        <img src="{{ .Params.image | relURL }}" alt="">
      </a>
      <div class="ms-2">
        <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 }}" class="line-clamp"> {{.Title | markdownify }}</a>
        </h2>
      </div>
    </li>
    {{ end }}
  </ol>
</section>
{{ end }}