setto-nostr-web/themes/one-pager/layouts/partials/blog.html
2026-07-31 09:46:08 +02:00

60 lines
2.7 KiB
HTML

<!-- BLOG SECTION - Longform -->
<section id="blog" class="section">
<h2>Now Log</h2>
<div class="blog-grid">
{{ $blogPosts := slice }}
{{ range $path, $entries := hugo.Data.longform }}
{{ range $entries }}
{{ $blogPosts = $blogPosts | append . }}
{{ end }}
{{ end }}
{{ $sortedPosts := sort $blogPosts "created_at" "desc" }}
{{ range first 2 $sortedPosts }}
{{ $title := "" }}
{{ $summary := "" }}
{{ $image := "" }}
{{ $tags := slice }}
{{ $d := "" }}
{{ $createdAt := int .created_at }}
{{ range .tags }}
{{ if eq (index . 0) "title" }}
{{ $title = index . 1 }}
{{ else if eq (index . 0) "summary" }}
{{ $summary = index . 1 }}
{{ else if eq (index . 0) "image" }}
{{ $image = index . 1 }}
{{ else if eq (index . 0) "t" }}
{{ $tags = $tags | append (index . 1) }}
{{ else if eq (index . 0) "d" }}
{{ $d = index . 1 }}
{{ end }}
{{ end }}
<div class="blog-card">
{{ if $image }}
<img src="{{ $image }}" alt="{{ $title }}" class="blog-header-image" loading="lazy">
{{ end }}
<div class="blog-content">
<h3>{{ $title }}</h3>
<p class="blog-meta">
{{ dateFormat "January 2, 2006" (time (int .created_at)) }}
</p>
{{ if $summary }}
<p class="blog-description">{{ $summary }}</p>
{{ end }}
<div class="blog-tags">
{{ range $tags }}
<span class="tag"><span>{{ . }}</span></span>
{{ end }}
</div>
<button class="read-more-toggle">Read More</button>
<div class="blog-full-content" style="display: none;">
{{ .content | markdownify }}
</div>
</div>
</div>
{{ end }}
</div>
</section>