summaryrefslogtreecommitdiff
path: root/layouts/partials/list
diff options
context:
space:
mode:
Diffstat (limited to 'layouts/partials/list')
-rw-r--r--layouts/partials/list/pagination.html28
-rw-r--r--layouts/partials/list/post-card.html45
-rw-r--r--layouts/partials/list/recent-posts.html50
3 files changed, 123 insertions, 0 deletions
diff --git a/layouts/partials/list/pagination.html b/layouts/partials/list/pagination.html
new file mode 100644
index 0000000..47d90ff
--- /dev/null
+++ b/layouts/partials/list/pagination.html
@@ -0,0 +1,28 @@
+{{- $paginator := . }}
+{{- if gt $paginator.TotalPages 1 }}
+<nav class="pagination" aria-label="{{ lang.Translate "pagination.label" | default "Page navigation" }}">
+ {{- if $paginator.HasPrev }}
+ <a href="{{ $paginator.Prev.URL }}"
+ class="pagination__link"
+ rel="prev"
+ aria-label="{{ lang.Translate "pagination.previous_page" | default "Previous page" }}"
+ >
+ ← {{ lang.Translate "common.previous" | default "Previous" }}
+ </a>
+ {{- end }}
+
+ <p class="pagination__current">
+ {{ lang.Translate "pagination.position" $paginator.PageNumber $paginator.TotalPages | default (printf "Page %d of %d" $paginator.PageNumber $paginator.TotalPages) }}
+ </p>
+
+ {{- if $paginator.HasNext }}
+ <a href="{{ $paginator.Next.URL }}"
+ class="pagination__link"
+ rel="next"
+ aria-label="{{ lang.Translate "pagination.next_page" | default "Next page" }}"
+ >
+ {{ lang.Translate "common.next" | default "Next" }} →
+ </a>
+ {{- end }}
+</nav>
+{{- end }}
diff --git a/layouts/partials/list/post-card.html b/layouts/partials/list/post-card.html
new file mode 100644
index 0000000..12eada4
--- /dev/null
+++ b/layouts/partials/list/post-card.html
@@ -0,0 +1,45 @@
+{{- $post := . }}
+<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__date">
+ {{ $post.Date | time.Format ":date_medium" }}
+ </time>
+ {{- with $post.ReadingTime }}
+ <p class="post-card__reading-time">
+ {{ lang.Translate "list.reading_time" . | default (printf "Estimated reading time: %s min" .) }}
+ </p>
+ {{- 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 "common.more" | default "more" }}
+ </span>
+ </li>
+ {{- end }}
+ </ul>
+ </footer>
+ {{- end }}
+</article>
diff --git a/layouts/partials/list/recent-posts.html b/layouts/partials/list/recent-posts.html
new file mode 100644
index 0000000..c1075e2
--- /dev/null
+++ b/layouts/partials/list/recent-posts.html
@@ -0,0 +1,50 @@
+{{- /*
+List of Recent Posts. Accepts a dict with the following optional parameters:
+
+@context {int} count: Number of posts to display (default: 10).
+@context {string} title: Section title (default: "Recent Articles").
+@context {bool} show_view_all: Whether to show "View All Posts" link (default: true).
+
+@example: {{ partial "list/recent-posts.html" (dict "count" 20 "title" "Latest updates" "show_view_all" true) }}
+*/ -}}
+
+{{- $count := .count | default 10 -}}
+{{- $title := .title | default (lang.Translate "posts.recent" | default "Recent Articles") -}}
+{{- $showViewAll := .show_view_all | default true -}}
+
+<section class="recent-posts" aria-labelledby="recent-posts-heading">
+ <header class="recent-posts__header">
+ <h2 id="recent-posts-heading" class="recent-posts__title">
+ {{ $title }}
+ </h2>
+ </header>
+
+ {{- /* Get published 10 most recent posts */ -}}
+ {{- $recentPosts := where site.RegularPages "Date" "!=" nil }}
+ {{- $recentPosts = where $recentPosts ".Date" "le" now }}
+ {{- $recentPosts = first $count $recentPosts }}
+
+ {{- if $recentPosts }}
+ <div class="recent-posts__content">
+ <ul class="recent-posts__list" role="list">
+ {{- range $recentPosts }}
+ <li class="recent-posts__list-item">
+ {{- partial "list/post-card.html" . }}
+ </li>
+ {{- end }}
+ </ul>
+
+ {{- if $showViewAll }}
+ <a href="{{ with site.GetPage "/posts" }}{{ .RelPermalink }}{{ else }}/posts/{{ end }}" class="recent_posts__view-all-link">
+ {{ lang.Translate "posts.view_all" | default "View all posts" }}
+ </a>
+ {{- end }}
+ </div>
+ {{ else }}
+ <div class="recent-posts__empty">
+ <p class="recent_posts__empty-message">
+ {{ lang.Translate "list.empty" | default "No posts in this section." }}
+ </p>
+ </div>
+ {{- end }}
+</section>