diff options
| author | Eltrac <hi@guhub.cn> | 2025-06-06 16:08:37 +0800 |
|---|---|---|
| committer | Eltrac <hi@guhub.cn> | 2025-06-06 16:08:37 +0800 |
| commit | e954f0d0560f36948fb123539629085f128f64e8 (patch) | |
| tree | 48518c0fae5ccd98e6fda6a5b6806420938b3f6a | |
| parent | fa48f611d0de8cbe389268ae3f356f307b6a4970 (diff) | |
refactor: reuse tag list
Former-commit-id: 17cc7da7218f24775bcdcbd1631c1d9380492d1d
| -rw-r--r-- | assets/css/components/_post.scss | 2 | ||||
| -rw-r--r-- | assets/css/components/_postlist.scss | 2 | ||||
| -rw-r--r-- | layouts/_default/featured.html | 8 | ||||
| -rw-r--r-- | layouts/partials/components/tags.html | 3 | ||||
| -rw-r--r-- | layouts/partials/items/card.html | 8 | ||||
| -rw-r--r-- | layouts/posts/single.html | 4 |
6 files changed, 9 insertions, 18 deletions
diff --git a/assets/css/components/_post.scss b/assets/css/components/_post.scss index 8f937d11..798fd665 100644 --- a/assets/css/components/_post.scss +++ b/assets/css/components/_post.scss @@ -24,7 +24,7 @@ gap: 0.5rem; align-items: center; - .post-date, .post-tag { + .post-date, .tag { color: var(--secondary-text-color) } diff --git a/assets/css/components/_postlist.scss b/assets/css/components/_postlist.scss index 171f2367..57c6b18f 100644 --- a/assets/css/components/_postlist.scss +++ b/assets/css/components/_postlist.scss @@ -31,7 +31,7 @@ time { font-family: var(--mono-font-family); } - a.post-tag { + a.tag { font-size: 0.8rem; color: var(--secondary-text-color); } diff --git a/layouts/_default/featured.html b/layouts/_default/featured.html index 8b599d27..86d5f53a 100644 --- a/layouts/_default/featured.html +++ b/layouts/_default/featured.html @@ -16,13 +16,9 @@ <header> <div class="posts-item-meta"> <p> - <time> - {{ .Date.Format "Jan 2, 2006" }} - </time> + <time>{{ .Date.Format "Jan 2, 2006" }}</time> <span>·</span> - {{ range .Params.tags }} - <a class="post-tag" href="{{ site.LanguagePrefix }}/tags/{{ lower . | urlize }}/">#{{ . }}</a> - {{ end }} + {{ partial "components/tags" . }} </p> <h2 class="posts-item-title"> <a diff --git a/layouts/partials/components/tags.html b/layouts/partials/components/tags.html new file mode 100644 index 00000000..6ff7f594 --- /dev/null +++ b/layouts/partials/components/tags.html @@ -0,0 +1,3 @@ +{{ range .Params.tags }} +<a class="tag" href="{{ site.LanguagePrefix }}/tags/{{ lower . | urlize }}/">#{{ . }}</a> +{{ end }} diff --git a/layouts/partials/items/card.html b/layouts/partials/items/card.html index 011d78fa..b8a3c7c1 100644 --- a/layouts/partials/items/card.html +++ b/layouts/partials/items/card.html @@ -10,13 +10,7 @@ data-weight="5"> <a href="{{ $ctx.RelPermalink }}">{{ $ctx.Title }}</a> </h3> - {{- if $ctx.Params.tags }} - <p class="card-tags"> - {{- range $ctx.Params.tags }} - <a href="{{ "/tags/" | relURL }}{{ . | urlize }}" class="card-tag">#{{ . }}</a> - {{- end }} - </p> - {{- end }} + <div class="card-tags">{{ partial "components/tags" $ctx }}</div> </div> <div class="card-content"> {{ if $showSummary }}{{ $ctx.Summary }}{{ else }}{{ $ctx.Content }}{{ end }} diff --git a/layouts/posts/single.html b/layouts/posts/single.html index 86d595d6..7a7051f0 100644 --- a/layouts/posts/single.html +++ b/layouts/posts/single.html @@ -19,9 +19,7 @@ {{ partial "components/date" . }} {{ if or .Params.categories .Params.tags }}<span>·</span>{{ end }} {{ partial "components/category-pill" . }} - {{ range .Params.tags }} - <a class="post-tag" href="{{ site.LanguagePrefix }}/tags/{{ lower . | urlize }}/">#{{ . }}</a> - {{ end }} + {{ partial "components/tags" . }} </div> </header> |
