From 9744b4d727c8c8764f8012a74f65b262d5ce7839 Mon Sep 17 00:00:00 2001 From: Xin Date: Sat, 28 Oct 2023 10:56:58 -0400 Subject: [PATCH] feat: option to show tags for blog list (#161) * feat: option to show tags for blog list * chore: update hugo_stats.json --- exampleSite/content/blog/markdown.md | 4 ++++ exampleSite/hugo.yaml | 4 ++++ exampleSite/hugo_stats.json | 1 + layouts/blog/list.html | 21 +++++++++++++++------ 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/exampleSite/content/blog/markdown.md b/exampleSite/content/blog/markdown.md index 782786f1..c4fb64e8 100644 --- a/exampleSite/content/blog/markdown.md +++ b/exampleSite/content/blog/markdown.md @@ -4,6 +4,10 @@ date: 2020-01-01 authors: - name: John Doe link: https://example.com/johndoe +tags: + - Markdown + - Example + - Guide excludeSearch: true --- diff --git a/exampleSite/hugo.yaml b/exampleSite/hugo.yaml index 418476f1..dcdaebba 100644 --- a/exampleSite/hugo.yaml +++ b/exampleSite/hugo.yaml @@ -136,6 +136,10 @@ params: enable: true base: "https://github.com/imfing/hextra/edit/main/exampleSite/content" + blog: + list: + displayTags: true + comments: enable: false type: giscus diff --git a/exampleSite/hugo_stats.json b/exampleSite/hugo_stats.json index 450bb8ce..faa572b7 100644 --- a/exampleSite/hugo_stats.json +++ b/exampleSite/hugo_stats.json @@ -402,6 +402,7 @@ "ml-1", "ml-4", "mr-2", + "mt-1", "mt-1.5", "mt-12", "mt-16", diff --git a/layouts/blog/list.html b/layouts/blog/list.html index a8026e5d..b22de2ec 100644 --- a/layouts/blog/list.html +++ b/layouts/blog/list.html @@ -1,6 +1,6 @@ {{ define "main" }} -{{- $readMore := (T "readMore") | default "Read more →" -}} -
+ {{- $readMore := (T "readMore") | default "Read more →" -}} +
{{ partial "sidebar.html" (dict "context" . "disableSidebar" true "displayPlaceholder" true) }}
@@ -10,11 +10,20 @@

{{ .Title }}

-

- {{- partial "utils/page-description" . }} - {{ $readMore }} + {{- if site.Params.blog.list.displayTags -}} + {{ with .Params.tags }} +

+ {{- range . }}#{{ . }}{{ end -}} +

+ {{ end -}} + {{- end -}} +

{{- partial "utils/page-description" . -}}

+

+ + {{- $readMore -}} +

-

{{ partial "utils/format-date" .Date }}

+

{{ partial "utils/format-date" .Date }}

{{ end }}