summaryrefslogtreecommitdiffstats
path: root/themes/danix-xyz-hacker/layouts/partials/article-list-item.html
blob: 29f8d2b175f565aa78a37d5ea3e46d6d83451a3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
{{ $articleType := .Params.type | default "life" }}
{{ $typeConfig := .Site.Params.articleTypes }}
{{ $typeData := index $typeConfig $articleType }}
{{ $excerpt := .Description | default .Summary }}

{{ $imageURL := "" }}
{{ if .Params.image }}
  {{ $resource := .Resources.GetMatch .Params.image }}
  {{ if $resource }}
    {{ $imageURL = $resource.RelPermalink }}
  {{ else }}
    {{ $imageURL = .Params.image }}
  {{ end }}
{{ end }}

<article class="border border-border/30 rounded-lg overflow-hidden hover:border-accent/50 transition-all duration-200 group bg-bg">
  <!-- Thumbnail -->
  {{ if $imageURL }}
  <a href="{{ .RelPermalink }}" class="block overflow-hidden bg-surface/50 relative" tabindex="-1">
    <img
      src="{{ $imageURL }}"
      alt="{{ .Title }}"
      class="w-full aspect-video object-cover group-hover:scale-105 transition-transform duration-200"
      loading="lazy"
    />
    <!-- Type badge pill overlay -->
    {{ if $typeData }}
    <div
      class="absolute top-3 right-3 px-3 py-1.5 rounded-full text-xs font-semibold text-white transition-opacity"
      style="background-color: var(--type-{{ $articleType }});"
    >
      {{ i18n $articleType }}
    </div>
    {{ end }}
  </a>
  {{ end }}

  <!-- Content -->
  <div class="p-5 md:p-6 space-y-3">
    <!-- Pinned badge -->
    {{ if .Params.pinned }}
    <div class="inline-flex items-center gap-1 px-2 py-1 rounded text-sm font-semibold" style="color: {{ .Site.Params.secondaryAccent }};">
      📌 PINNED
    </div>
    {{ end }}

    <!-- Title -->
    <h3 class="text-xl font-semibold">
      <a href="{{ .RelPermalink }}" class="group-hover:text-accent transition-colors">
        {{ .Title }}
      </a>
    </h3>

    <!-- Metadata -->
    <div class="flex flex-wrap items-center gap-3 text-sm text-text-dim">
      <!-- Publish date -->
      <time datetime="{{ .PublishDate.Format "2006-01-02T15:04:05Z07:00" }}">
        {{ .PublishDate.Format "Jan 2, 2006" }}
      </time>
    </div>

    <!-- Excerpt -->
    {{ if $excerpt }}
    <p class="text-text-dim text-sm line-clamp-3 leading-relaxed">
      {{ $excerpt | plainify }}
    </p>
    {{ end }}

    <!-- CTA Button -->
    <a
      href="{{ .RelPermalink }}"
      class="inline-flex items-center gap-2 px-3 py-2 rounded border border-border/30 text-sm font-medium hover:border-accent/50 hover:text-accent transition-colors group/cta"
    >
      {{ i18n "readMore" }}
      <i data-feather="arrow-right" class="w-4 h-4 group-hover/cta:translate-x-1 transition-transform"></i>
    </a>
  </div>
</article>