summaryrefslogtreecommitdiff
path: root/layouts
diff options
context:
space:
mode:
Diffstat (limited to 'layouts')
-rw-r--r--layouts/_default/all-posts.html2
-rw-r--r--layouts/_default/list.html2
-rw-r--r--layouts/_default/search.html3
-rw-r--r--layouts/index.json1
-rw-r--r--layouts/partials/list/post-card.html23
-rw-r--r--layouts/partials/list/recent-posts.html2
-rw-r--r--layouts/tags/term.html2
7 files changed, 26 insertions, 9 deletions
diff --git a/layouts/_default/all-posts.html b/layouts/_default/all-posts.html
index d2ce8ee..dcfe74e 100644
--- a/layouts/_default/all-posts.html
+++ b/layouts/_default/all-posts.html
@@ -22,7 +22,7 @@
<ul class="all-posts__list" role="list">
{{- range $allPosts.ByDate.Reverse }}
<li class="all-posts__list-item">
- {{ partial "list/post-card.html" . }}
+ {{ partial "list/post-card.html" (dict "post" . "show_category" true) }}
</li>
{{- end }}
</ul>
diff --git a/layouts/_default/list.html b/layouts/_default/list.html
index fb53b40..f952e56 100644
--- a/layouts/_default/list.html
+++ b/layouts/_default/list.html
@@ -23,7 +23,7 @@
<ul class="list-page__posts-list">
{{- range . }}
<li class="list-page__post">
- {{- partial "list/post-card.html" . }}
+ {{- partial "list/post-card.html" (dict "post" .) }}
</li>
{{- end }}
</ul>
diff --git a/layouts/_default/search.html b/layouts/_default/search.html
index 90a6357..b501c8b 100644
--- a/layouts/_default/search.html
+++ b/layouts/_default/search.html
@@ -55,12 +55,13 @@
{{- $mockPost := dict
"Title" "TEMPLATE_TITLE"
"RelPermalink" "TEMPLATE_URL"
+ "Section" "TEMPLATE_SECTION"
"Date" now
"Summary" "TEMPLATE_SUMMARY"
"Params" (dict "tags" (slice "TEMPLATE_TAG"))
-}}
<li class="search-results__list-item">
- {{- partial "list/post-card.html" $mockPost }}
+ {{- partial "list/post-card.html" (dict "post" $mockPost "show_category" true) }}
</li>
</template>
diff --git a/layouts/index.json b/layouts/index.json
index 29d7e14..00a7048 100644
--- a/layouts/index.json
+++ b/layouts/index.json
@@ -5,6 +5,7 @@
"title" .Title
"summary" (.Summary | plainify | htmlUnescape)
"url" .RelPermalink
+ "section" (lang.translate (.Section | singularize) | default (.Section | singularize | title))
"date" (.Date.Format "2006-01-02T15:04:05Z07:00")
"tags" .Params.tags
-}}
diff --git a/layouts/partials/list/post-card.html b/layouts/partials/list/post-card.html
index 955e868..b35c724 100644
--- a/layouts/partials/list/post-card.html
+++ b/layouts/partials/list/post-card.html
@@ -1,4 +1,14 @@
-{{- $post := . }}
+{{- /*
+Card with a summary of and link to a post. Accepts a dict with the following optional parameters:
+
+@context {Page} post: The post to display (default: .).
+@context {bool} show_category: Whether to display a badge with the name of the category/section the post was published under (default: true).
+
+@example: {{ partial "list/post-card.html" (dict "post" . "show_category" true) }}
+*/ -}}
+
+{{- $post := .post }}
+{{- $showCategory := .show_category | default false }}
<article class="post-card">
<header class="post-card__header">
<h3 class="post-card__title">
@@ -13,14 +23,20 @@
<!-- 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) }}
+ • {{ 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) }}
+ {{ lang.Translate "word_count" $post.WordCount | default (printf "%s words" $post.WordCount) }} •
</span>
</p>
-->
+ {{- if $showCategory }}
+ {{- $section := $post.Section }}
+ <span class="post-card__section-badge">
+ {{ lang.Translate ($section | singularize) | default ($section | singularize | title) }}
+ </span>
+ {{- end }}
</div>
</header>
@@ -47,6 +63,5 @@
{{- end }}
</ul>
</footer>
- <hr />
{{- end }}
</article>
diff --git a/layouts/partials/list/recent-posts.html b/layouts/partials/list/recent-posts.html
index 5426f70..f42af13 100644
--- a/layouts/partials/list/recent-posts.html
+++ b/layouts/partials/list/recent-posts.html
@@ -24,7 +24,7 @@ List of specified number of the most recent and published posts. Accepts a dict
<ul class="recent-posts__list" role="list">
{{- range $recentPosts }}
<li class="recent-posts__list-item">
- {{- partial "list/post-card.html" . }}
+ {{- partial "list/post-card.html" (dict "post" . "show_category" true) }}
</li>
{{- end }}
</ul>
diff --git a/layouts/tags/term.html b/layouts/tags/term.html
index cb7d1b0..8a259c2 100644
--- a/layouts/tags/term.html
+++ b/layouts/tags/term.html
@@ -20,7 +20,7 @@
<ul class="tag-page__posts-list">
{{- range . }}
<li class="tag-page__post">
- {{- partial "list/post-card.html" . }}
+ {{- partial "list/post-card.html" (dict "post" . "show_category" true) }}
</li>
{{- end }}
</ul>