Skip to content
This repository was archived by the owner on Mar 9, 2022. It is now read-only.

Commit

Permalink
fix(path): broken tag/category link when containing a dot (#368)
Browse files Browse the repository at this point in the history
  • Loading branch information
wtchangdm authored May 18, 2020
1 parent 9c12444 commit e5ae1d6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
6 changes: 3 additions & 3 deletions layouts/_default/summary.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ <h1 class="single-title" itemprop="name headline">

{{- $categories := slice -}}
{{- range .Params.categories -}}
{{- $category := . | anchorize | printf "/categories/%v" | $.Site.GetPage -}}
{{- $category := partialCached "function/path.html" . . | printf "/categories/%v" | $.Site.GetPage -}}
{{- $categories = $categories | append (printf `<a href="%v"><i class="far fa-folder fa-fw"></i>%v</a>` $category.RelPermalink $category.Title) -}}
{{- end -}}
{{- with delimit $categories "&nbsp;" -}}
Expand All @@ -58,10 +58,10 @@ <h1 class="single-title" itemprop="name headline">
<i class="fas fa-tags fa-fw"></i>&nbsp;
{{- range $index, $value := . -}}
{{- if gt $index 0 }},&nbsp;{{ end -}}
{{- $tag := $value | anchorize | printf "/tags/%v" | $.Site.GetPage -}}
{{- $tag := partialCached "function/path.html" $value $value | printf "/tags/%v" | $.Site.GetPage -}}
<a href="{{ $tag.RelPermalink }}">{{ $tag.Title }}</a>
{{- end -}}
</div>
{{- end -}}
</div>
</article>
</article>
3 changes: 3 additions & 0 deletions layouts/partials/function/path.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{- /* https://discourse.gohugo.io/t/how-decode-urls-in-hugo/7549/4 */ -}}
{{- $URL := . | urlize | urls.Parse -}}
{{- return $URL.Path -}}
2 changes: 1 addition & 1 deletion layouts/partials/single/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<i class="fas fa-tags fa-fw"></i>&nbsp;
{{- range $index, $value := . -}}
{{- if gt $index 0 }},&nbsp;{{ end -}}
{{- $tag := $value | anchorize | printf "/tags/%v" | $.Site.GetPage -}}
{{- $tag := partialCached "function/path.html" $value $value | printf "/tags/%v" | $.Site.GetPage -}}
<a href="{{ $tag.RelPermalink }}">{{ $tag.Title }}</a>
{{- end -}}
{{- end -}}
Expand Down
2 changes: 1 addition & 1 deletion layouts/posts/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ <h2 class="single-subtitle">{{ . }}</h2>

{{- $categories := slice -}}
{{- range .Params.categories -}}
{{- $category := . | anchorize | printf "/categories/%v" | $.Site.GetPage -}}
{{- $category := partialCached "function/path.html" . . | printf "/categories/%v" | $.Site.GetPage -}}
{{- $categories = $categories | append (printf `<a href="%v"><i class="far fa-folder fa-fw"></i>%v</a>` $category.RelPermalink $category.Title) -}}
{{- end -}}
{{- with delimit $categories "&nbsp;" -}}
Expand Down

0 comments on commit e5ae1d6

Please sign in to comment.