summaryrefslogtreecommitdiff
path: root/layouts/_partials/list/post-card.html
diff options
context:
space:
mode:
Diffstat (limited to 'layouts/_partials/list/post-card.html')
-rw-r--r--layouts/_partials/list/post-card.html66
1 files changed, 66 insertions, 0 deletions
diff --git a/layouts/_partials/list/post-card.html b/layouts/_partials/list/post-card.html
new file mode 100644
index 0000000..6444701
--- /dev/null
+++ b/layouts/_partials/list/post-card.html
@@ -0,0 +1,66 @@
+{{- /*
+Card with a summary of and link to a post. Accepts a dict with the following parameters:
+
+@context {Page} post: The post to display.
+@context {bool} show_section: Whether to display a badge with the name of the section the post was published under (default: false).
+
+@example: {{ partial "list/post-card.html" (dict "post" . "show_section" true) }}
+*/ -}}
+
+{{- $post := .post -}}
+{{- $showSection := .show_section | default false -}}
+<article class="post-card">
+ <header class="post-card__header">
+ <h3 class="post-card__title">
+ <a href="{{ $post.RelPermalink }}" class="post-card__link">
+ {{ $post.Title }}
+ </a>
+ </h3>
+ <div class="post-card__meta">
+ <time datetime="{{ $post.Date.Format "2006-01-02T15:04:05Z07:00" }}" class="post-card__publish-date">
+ {{ $post.Date | time.Format ":date_medium" }}
+ </time>
+ <!-- Uncomment for post meta info
+ <p class="post-card__meta-info">
+ <span class="post-card__reading-time">
+ • {{ lang.Translate "reading_time" $post.ReadingTime | default (printf "Estimated reading time: %s min" $post.ReadingTime) }}
+ </span>
+ |
+ <span class="post-card__word-count">
+ {{ lang.Translate "word_count" $post.WordCount | default (printf "%s words" $post.WordCount) }} •
+ </span>
+ </p>
+ -->
+ {{- if $showSection }}
+ <span class="post-card__section-badge">
+ {{ lang.Translate ($post.Section | singularize) | default ($post.Section | singularize | title) }}
+ </span>
+ {{- end }}
+ </div>
+ </header>
+
+ {{- with $post.Summary }}
+ <div class="post-card__summary">
+ {{ . }}
+ </div>
+ {{- end }}
+
+ {{- with $post.Params.tags }}
+ <footer class="post-card__tags">
+ <ul class="post-card__tags-list">
+ {{- range first 3 . }}
+ <li class="post-card__tags-item">
+ #{{ . }}
+ </li>
+ {{- end }}
+ {{- if gt (len .) 3 }}
+ <li class="post-card__tags-item post-card__tags-more">
+ <span class="post-card__tags-more-count">
+ +{{ sub (len .) 3 }} {{ lang.Translate "more" | default "more" }}
+ </span>
+ </li>
+ {{- end }}
+ </ul>
+ </footer>
+ {{- end }}
+</article>