mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 23:38:56 +00:00
⚡ Perf: optimize code
This commit is contained in:
@@ -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>` (replace $category.RelPermalink "#" "%23") (dict "Class" "fa-regular fa-folder fa-fw" | partial "plugin/icon.html") $category.Title) -}}
|
||||
{{- $categories = $categories | append (printf `<a href="%v">%v %v</a>` (partial "function/escapeurl.html" $category.RelPermalink) (dict "Class" "fa-regular fa-folder fa-fw" | partial "plugin/icon.html") $category.Title) -}}
|
||||
{{- end -}}
|
||||
{{- with delimit $categories " " -}}
|
||||
<span class="post-category">
|
||||
@@ -70,7 +70,7 @@
|
||||
{{- range $value := . -}}
|
||||
{{- $tag := partialCached "function/path.html" $value $value | printf "/tags/%v" | $.Site.GetPage -}}
|
||||
{{- with $tag -}}
|
||||
<a href='{{ replace .RelPermalink "#" "%23" }}' class="post-tag">{{ .Title }}</a>
|
||||
<a href='{{ partial "function/escapeurl.html" .RelPermalink }}' class="post-tag">{{ .Title }}</a>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{{- /* https://discourse.gohugo.io/t/how-decode-urls-in-hugo/7549/4 */ -}}
|
||||
{{- $URL := partial "function/urlquery.html" . -}}
|
||||
{{- $URL := partial "function/escapeurl.html" . -}}
|
||||
{{- $URL = $URL | urlize | urls.Parse -}}
|
||||
{{- return $URL.Path -}}
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
{{- range $value := . -}}
|
||||
{{- $tag := partialCached "function/path.html" $value $value | printf "/tags/%v" | $.Site.GetPage -}}
|
||||
{{- with $tag -}}
|
||||
<a href='{{ replace .RelPermalink "#" "%23" }}' class="post-tag">{{ .Title }}</a>
|
||||
<a href='{{ partial "function/escapeurl.html" .RelPermalink }}' class="post-tag">{{ .Title }}</a>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -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>` (replace $category.RelPermalink "#" "%23") (dict "Class" "fa-regular fa-folder fa-fw" | partial "plugin/icon.html") $category.Title) -}}
|
||||
{{- $categories = $categories | append (printf `<a href="%v">%v %v</a>` (partial "function/escapeurl.html" $category.RelPermalink) (dict "Class" "fa-regular fa-folder fa-fw" | partial "plugin/icon.html") $category.Title) -}}
|
||||
{{- end -}}
|
||||
{{- with delimit $categories " " }}
|
||||
<span class="post-category">
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<div class="card-item">
|
||||
<div class="card-item-wrapper">
|
||||
<h3 class="card-item-title">
|
||||
<a href='{{ replace .RelPermalink "#" "%23" }}'>
|
||||
<a href='{{ partial "function/escapeurl.html" .RelPermalink }}'>
|
||||
{{ dict "Class" "fa-regular fa-folder fa-fw" | partial "plugin/icon.html" }}
|
||||
{{ .Page.Title }} <sup>{{- len $pages -}}</sup>
|
||||
</a>
|
||||
@@ -36,7 +36,7 @@
|
||||
{{- end -}}
|
||||
{{- if gt (len $pages) 5 -}}
|
||||
<span class="more-post">
|
||||
<a href='{{ replace .RelPermalink "#" "%23" }}' class="more-single-link">{{ T "more" }} >></a>
|
||||
<a href='{{ partial "function/escapeurl.html" .RelPermalink }}' 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='{{ replace .Page.RelPermalink "#" "%23" }}' class="tag-cloud-{{ $grade }}" style="--tag-font: {{ $fontSize }}px">{{ .Page.Title }} <sup>{{ .Count }}</sup></a>
|
||||
<a href='{{ partial "function/escapeurl.html" .Page.RelPermalink }}' class="tag-cloud-{{ $grade }}" style="--tag-font: {{ $fontSize }}px">{{ .Page.Title }} <sup>{{ .Count }}</sup></a>
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- range $.Site.Taxonomies.tags.ByCount -}}
|
||||
<a href='{{ replace .Page.RelPermalink "#" "%23" }}'>{{ .Page.Title }} <sup>{{ .Count }}</sup></a>
|
||||
<a href='{{ partial "function/escapeurl.html" .Page.RelPermalink }}'>{{ .Page.Title }} <sup>{{ .Count }}</sup></a>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user