Skip to content

Commit

Permalink
fix: custom title for taxonomies (#45)
Browse files Browse the repository at this point in the history
Co-authored-by: Tinko <24890691+TinkoLiu@users.noreply.github.com>
  • Loading branch information
TinkoLiu and TinkoLiu authored Jun 26, 2024
1 parent 6aeb747 commit f9bfe84
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 6 deletions.
4 changes: 4 additions & 0 deletions exampleSite/content/categories/with-slug/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: A Category with Slug
slug: with-slug
---
4 changes: 4 additions & 0 deletions exampleSite/content/categories/with-slug/_index.zh-cn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: 自定义 Slug 的分类
slug: with-slug
---
3 changes: 2 additions & 1 deletion exampleSite/content/post/image-process/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ author = "Hugo Authors"
title = "Image Process"
date = "2023-12-01"
description = "Demo of Hugo's image processing"
tags = []
tags = ["custom"]
toc = false
image = "images/hugo-logo-wide.svg"
categories = ["with-slug"]
+++

![Photo by Behnam Norouzi on Unsplash](./images/behnam-norouzi-_1ok63FFlM4-unsplash.jpg "Photo by Behnam Norouzi on Unsplash")
Expand Down
3 changes: 2 additions & 1 deletion exampleSite/content/post/image-process/index.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ author = "Hugo Authors"
title = "图片处理"
date = "2023-12-01"
description = "关于Hugo中图片处理的示例"
tags = []
tags = ["custom"]
toc = false
image = "images/hugo-logo-wide.svg"
categories = ["with-slug"]
+++

![Photo by Behnam Norouzi on Unsplash](./images/behnam-norouzi-_1ok63FFlM4-unsplash.jpg "Photo by Behnam Norouzi on Unsplash")
Expand Down
4 changes: 4 additions & 0 deletions exampleSite/content/tags/custom/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: CustomTag
slug: custom
---
4 changes: 4 additions & 0 deletions exampleSite/content/tags/custom/_index.zh-cn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: 随便一个标签
slug: custom
---
8 changes: 4 additions & 4 deletions layouts/partials/block/taxonomies.html
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
{{ if (or .Params.categories .Params.tags) }}
<ul class="flex flex-row flex-wrap text-slate-500 dark:text-slate-300">
{{ if .Params.categories }}
{{ range .Params.categories }}
{{ range (.GetTerms "categories") }}
<li>
<a href="{{ (urlize (printf "categories/%s" . )) | relLangURL }}/"
class="text-sm mr-2 px-2 py-1 rounded border border-emerald-800 bg-emerald-800 text-slate-50">
{{ . }}
{{ .LinkTitle }}
</a>
</li>
{{ end }}
{{ end }}
{{ if .Params.tags }}
{{ range .Params.tags }}
{{ range (.GetTerms "tags") }}
<li>
<a href="{{ (urlize (printf "tags/%s" . )) | relLangURL }}/"
class="flex flex-row text-sm mr-2 py-1">
<i class="h-5 w-5 flex-none">
{{ partial "icon.html" site.Params.taxonomies.icons.tags }}
</i>
<span class="ml-0">{{ . }}</span>
<span class="ml-0">{{ .LinkTitle }}</span>
</a>
</li>
{{ end }}
Expand Down

0 comments on commit f9bfe84

Please sign in to comment.