🐛 Fix: escape hashtag character # in tag and category (#245)

This commit is contained in:
Cell
2022-11-18 12:58:02 +08:00
parent 88ec9f6e8a
commit 908cb6946b
8 changed files with 31 additions and 15 deletions
+1
View File
@@ -22,6 +22,7 @@ All notable changes to this project will be documented in this file.
- :bento: Fix: update webfonts for fontawesome 6.2.0 (@NicoDreamzZ[#228](https://github.com/hugo-fixit/FixIt/pull/228))
- :bug: Fix: image shortcode/plugin lose the support for svg type files ([#210](https://github.com/hugo-fixit/FixIt/issues/210))
- :bug: Fix: can't keep the static table of the contents in front of the post
- :bug: Fix: escape hashtag character `#` in tag and category ([#245](https://github.com/hugo-fixit/FixIt/issues/245))
- :lipstick: Style: refactor css style
- :lipstick: Style: update home page stylesheet
- :wrench: Chore(deps-dev):
+5
View File
@@ -177,6 +177,11 @@
padding: 0;
@include link(true, true);
.post-tag:not(:last-child)::after {
content: ',';
margin-right: 0.25rem;
}
}
}
}
@@ -73,6 +73,13 @@
* {
display: inline;
}
@include link(true, true);
.post-tag:not(:last-child)::after {
content: ',';
margin-right: 0.25rem;
}
}
.post-nav {
+6 -5
View File
@@ -43,7 +43,7 @@
{{- $categories := slice -}}
{{- range .Params.categories -}}
{{- $category := partialCached "function/path.html" . . | printf "/categories/%v" | $.Site.GetPage -}}
{{- $categories = $categories | append (printf `<a href="%v">%v %v</a>` $category.RelPermalink (dict "Class" "fa-regular fa-folder fa-fw" | partial "plugin/icon.html") $category.Title) -}}
{{- $categories = $categories | append (printf `<a href="%v">%v %v</a>` (replace $category.RelPermalink "#" "%23") (dict "Class" "fa-regular fa-folder fa-fw" | partial "plugin/icon.html") $category.Title) -}}
{{- end -}}
{{- with delimit $categories "&ensp;" -}}
&nbsp;<span class="post-category">
@@ -66,11 +66,12 @@
<a href="{{ .RelPermalink }}">{{ T "readMore" }}</a>
{{- with .Params.tags -}}
<div class="post-tags">
{{- dict "Class" "fa-solid fa-tags fa-fw" | partial "plugin/icon.html" -}}&nbsp;
{{- range $index, $value := . -}}
{{- if gt $index 0 }},&nbsp;{{ end -}}
{{- dict "Class" "fa-solid fa-tags fa-fw me-1" | partial "plugin/icon.html" -}}
{{- range $value := . -}}
{{- $tag := partialCached "function/path.html" $value $value | printf "/tags/%v" | $.Site.GetPage -}}
<a href="{{ $tag.RelPermalink }}">{{ $tag.Title }}</a>
{{- with $tag -}}
<a href='{{ replace .RelPermalink "#" "%23" }}' class="post-tag">{{ .Title }}</a>
{{- end -}}
{{- end -}}
</div>
{{- end -}}
+2 -1
View File
@@ -1,3 +1,4 @@
{{- /* https://discourse.gohugo.io/t/how-decode-urls-in-hugo/7549/4 */ -}}
{{- $URL := . | urlize | urls.Parse -}}
{{- /* https://github.com/hugo-fixit/FixIt/issues/245 */ -}}
{{- $URL := . | urlize | urlquery | urls.Parse -}}
{{- return $URL.Path -}}
+5 -4
View File
@@ -59,11 +59,12 @@
<div class="post-info-more">
<section class="post-tags">
{{- with .Params.tags -}}
{{- dict "Class" "fa-solid fa-tags fa-fw" | partial "plugin/icon.html" -}}&nbsp;
{{- range $index, $value := . -}}
{{- if gt $index 0 }},&nbsp;{{ end -}}
{{- dict "Class" "fa-solid fa-tags fa-fw me-1" | partial "plugin/icon.html" -}}
{{- range $value := . -}}
{{- $tag := partialCached "function/path.html" $value $value | printf "/tags/%v" | $.Site.GetPage -}}
<a href="{{ $tag.RelPermalink }}">{{ $tag.Title }}</a>
{{- with $tag -}}
<a href='{{ replace .RelPermalink "#" "%23" }}' class="post-tag">{{ .Title }}</a>
{{- end -}}
{{- end -}}
{{- end -}}
</section>
+1 -1
View File
@@ -52,7 +52,7 @@
{{- $categories := slice -}}
{{- range .Params.categories -}}
{{- $category := partialCached "function/path.html" . . | printf "/categories/%v" | $.Site.GetPage -}}
{{- $categories = $categories | append (printf `<a href="%v">%v %v</a>` $category.RelPermalink (dict "Class" "fa-regular fa-folder fa-fw" | partial "plugin/icon.html") $category.Title) -}}
{{- $categories = $categories | append (printf `<a href="%v">%v %v</a>` (replace $category.RelPermalink "#" "%23") (dict "Class" "fa-regular fa-folder fa-fw" | partial "plugin/icon.html") $category.Title) -}}
{{- end -}}
{{- with delimit $categories "&ensp;" }}
<span class="post-category">
+4 -4
View File
@@ -24,7 +24,7 @@
<div class="card-item">
<div class="card-item-wrapper">
<h3 class="card-item-title">
<a href="{{ .RelPermalink }}">
<a href='{{ replace .RelPermalink "#" "%23" }}'>
{{ dict "Class" "fa-regular fa-folder fa-fw" | partial "plugin/icon.html" }}
{{ .Page.Title }}&nbsp;<sup>{{- len $pages -}}</sup>
</a>
@@ -36,7 +36,7 @@
{{- end -}}
{{- if gt (len $pages) 5 -}}
<span class="more-post">
<a href="{{ .RelPermalink }}" class="more-single-link">{{ T "more" }} >></a>
<a href='{{ replace .RelPermalink "#" "%23" }}' class="more-single-link">{{ T "more" }} >></a>
</span>
{{- end -}}
</div>
@@ -57,11 +57,11 @@
{{- range $tags -}}
{{- $grade := math.Min (math.Floor (div (sub .Count 1) $baseGrade)) 10 -}}
{{- $fontSize := add $minFont (mul $grade $baseFont) -}}
<a href="{{ .Page.RelPermalink }}" class="tag-cloud-{{ $grade }}" style="--tag-font: {{ $fontSize }}px">{{ .Page.Title }} <sup>{{ .Count }}</sup></a>
<a href='{{ replace .Page.RelPermalink "#" "%23" }}' class="tag-cloud-{{ $grade }}" style="--tag-font: {{ $fontSize }}px">{{ .Page.Title }} <sup>{{ .Count }}</sup></a>
{{- end -}}
{{- else -}}
{{- range $.Site.Taxonomies.tags.ByCount -}}
<a href="{{ .Page.RelPermalink }}">{{ .Page.Title }} <sup>{{ .Count }}</sup></a>
<a href='{{ replace .Page.RelPermalink "#" "%23" }}'>{{ .Page.Title }} <sup>{{ .Count }}</sup></a>
{{- end -}}
{{- end -}}
</div>