{{ define "main" }}
  <div class="hx:mx-auto hx:flex hextra-max-page-width">
    {{ partial "sidebar.html" (dict "context" . "disableSidebar" true) }}
    <main
      id="content"
      class="hx:w-full hx:break-words hx:min-h-[calc(100vh-var(--hextra-navbar-height))] hx:min-w-0 hx:pb-8 hx:pt-8 hx:md:pt-12 hx:pl-[max(env(safe-area-inset-left),1.5rem)] hx:pr-[max(env(safe-area-inset-right),1.5rem)]"
    >
      {{ partial "custom/page-begin.html" . }}
      <div class="hx:flex hx:flex-col hx:items-start">
        {{ partial "custom/content-begin.html" . }}
        {{ .Content }}

        {{/* Blog posts section */}}
        {{ $posts := where site.RegularPages "Section" "posts" }}
        {{ if $posts }}
        <div style="height:48px"></div>
        <div>
          <h2 class="hx:text-2xl hx:font-bold hx:tracking-tight hx:text-slate-900 hx:dark:text-slate-100">最近文章</h2>
        </div>
        <div style="height:16px"></div>
        <div class="hx:w-full" style="display:flex;flex-direction:column;gap:20px">
          {{ range first 5 $posts }}
          <a href="{{ .RelPermalink }}" style="display:block;text-decoration:none;color:inherit;padding:16px;border-radius:12px;border:1px solid #e5e7eb;transition:border-color 0.2s,box-shadow 0.2s" onmouseover="this.style.borderColor='#1f2937';this.style.boxShadow='0 2px 8px rgba(0,0,0,0.06)'" onmouseout="this.style.borderColor='#e5e7eb';this.style.boxShadow='none'">
            <h3 style="margin:0 0 4px 0;font-size:1.125rem;font-weight:600;color:#1e293b" class="hx:dark:text-slate-100">{{ .Title }}</h3>
            {{ with .Description }}<p style="margin:0;font-size:0.875rem;color:#6b7280;line-height:1.6;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden" class="hx:dark:text-gray-400">{{ . }}</p>{{ end }}
            <div style="margin-top:8px;display:flex;align-items:center;gap:8px;font-size:0.75rem;color:#9ca3af" class="hx:dark:text-gray-500">
              <time>{{ .Date.Format "2006/01/02" }}</time>
              {{ range .Params.tags }}
                <span style="padding:2px 6px;border-radius:4px;background:#f3f4f6;color:#4b5563" class="hx:dark:bg-neutral-800 hx:dark:text-gray-400">{{ . }}</span>
              {{ end }}
            </div>
          </a>
          {{ end }}
        </div>
        {{ end }}

        {{ partial "custom/content-end.html" . }}
      </div>
      {{ partial "custom/page-end.html" . }}
    </main>
  </div>
{{ end }}
