diff options
author | Jimmy Cai <jimmehcai@gmail.com> | 2020-09-13 11:14:17 +0300 |
---|---|---|
committer | Jimmy Cai <jimmehcai@gmail.com> | 2020-09-13 11:14:17 +0300 |
commit | 2451b194dc022b9a2b6ad23c3ec819d3ddb7e1cb (patch) | |
tree | 024621304abf331564df85818b3e27ca7c8dc647 | |
parent | 822eba9513f8e3a29ba280c15a1a9c96c82d4c93 (diff) |
refactor: use relLangURL to build relative links
For better i18n support
Fixes archive page path
Remove tag cloud term exclusion
closes https://github.com/CaiJimmy/hugo-theme-stack/issues/8
-rw-r--r-- | layouts/partials/article/components/details.html | 4 | ||||
-rw-r--r-- | layouts/partials/article/components/footer.html | 2 | ||||
-rw-r--r-- | layouts/partials/widget/archive.html | 4 | ||||
-rw-r--r-- | layouts/partials/widget/tag-cloud.html | 5 |
4 files changed, 7 insertions, 8 deletions
diff --git a/layouts/partials/article/components/details.html b/layouts/partials/article/components/details.html index 0a8f777..1b776be 100644 --- a/layouts/partials/article/components/details.html +++ b/layouts/partials/article/components/details.html @@ -7,10 +7,10 @@ {{ if and $image.exists $image.resource }} {{- $imageRaw := $image.resource | resources.Fingerprint "md5" -}} {{- $20x := $imageRaw.Fill "20x20 smart" -}} - <a href="/categories/{{ . | urlize }}" class="color-tag" + <a href="{{ printf `categories/%s` (. | urlize) | relLangURL }}" class="color-tag" data-image="{{ $20x.RelPermalink }}" data-key="{{ $context.Slug }}" data-hash="{{ $imageRaw.Data.Integrity }}">{{ . | humanize }}</a> {{ else }} - <a href="/categories/{{ . | urlize }}">{{ . | humanize }}</a> + <a href="{{ printf `categories/%s` (. | urlize) | relLangURL }}">{{ . | humanize }}</a> {{ end }} {{ end }} </header> diff --git a/layouts/partials/article/components/footer.html b/layouts/partials/article/components/footer.html index 9787f8f..102bc4a 100644 --- a/layouts/partials/article/components/footer.html +++ b/layouts/partials/article/components/footer.html @@ -2,7 +2,7 @@ {{ with $tags := .Params.Tags }} <section class="article-tags"> {{ range $tags }} - <a href="/tags/{{ . | urlize }}">{{ . | humanize }}</a> + <a href="{{ printf `tags/%s` (. | urlize) | relLangURL }}">{{ . | humanize }}</a> {{ end }} </section> {{ end }} diff --git a/layouts/partials/widget/archive.html b/layouts/partials/widget/archive.html index 22b3236..1dae730 100644 --- a/layouts/partials/widget/archive.html +++ b/layouts/partials/widget/archive.html @@ -12,7 +12,7 @@ {{ range first .Site.Params.widgets.archive.limit ($archive) }} {{ $id := lower (replace .Key " " "-") }} <div class="archive-year"> - <a href="{{ $.Site.BaseURL }}{{ $.Site.Params.widgets.archive.path }}#{{ $id }}"> + <a href="{{ $.Site.Params.widgets.archive.path | relLangURL }}#{{ $id }}"> <span class="year">{{ .Key }}</span> <span class="count">{{ len .Pages }}</span> </a> @@ -21,7 +21,7 @@ {{ if gt (len $archive) .Site.Params.widgets.archive.limit }} <div class="archive-year"> - <a href="{{ $.Site.BaseURL }}/archive"> + <a href="{{ $.Site.Params.widgets.archive.path | relLangURL }}"> <span class="year">{{ T "widgetArchiveMore" }}</span> </a> </div> diff --git a/layouts/partials/widget/tag-cloud.html b/layouts/partials/widget/tag-cloud.html index fbc4778..1fa8efe 100644 --- a/layouts/partials/widget/tag-cloud.html +++ b/layouts/partials/widget/tag-cloud.html @@ -1,5 +1,4 @@ {{ $tags := .Site.Taxonomies.tags.ByCount }} -{{ $v2 := where $tags "Term" "not in" (slice "hugo" "tag" "rss") }} <section class="widget tagCloud"> <div class="widget-icon"> @@ -8,8 +7,8 @@ <h1 class="widget-title">{{ T "widgetTagCloudTitle" }}</h1> <div class="tagCloud-tags"> - {{ range first .Site.Params.widgets.tagCloud.limit $v2 }} - <a href="{{ $.Site.BaseURL }}tags/{{ .Term | urlize }}/" class="font_size_{{ .Count }}"> + {{ range first .Site.Params.widgets.tagCloud.limit $tags }} + <a href="{{ printf `tags/%s` (.Term | urlize) | relLangURL }}" class="font_size_{{ .Count }}"> {{ .Term | humanize }} </a> {{ end }} |