diff options
author | Mattia Panzeri <mattia.panzeri93@gmail.com> | 2020-12-29 14:46:45 +0300 |
---|---|---|
committer | dataCobra <datacobra@thinkbot.de> | 2021-02-06 18:00:05 +0300 |
commit | fb4da6dd00d6b5515908a088e8b5b47781ae6ebe (patch) | |
tree | 358f8877e1b13e3145f0c83c078462ada87faa39 | |
parent | fed993d2351df00467c17a91083f38f1bad9a511 (diff) |
fix(layouts): Replace custom truncate logic with built-in method
-rw-r--r-- | layouts/_default/list.html | 10 | ||||
-rw-r--r-- | layouts/_default/rss.xml | 10 | ||||
-rw-r--r-- | layouts/index.html | 6 |
3 files changed, 10 insertions, 16 deletions
diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 8c2df5a..3f9e39f 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -31,13 +31,11 @@ {{ end }} </div> <span class="description"> - {{ if isset .Params "description" }} + {{ if isset .Params "description" }} {{ .Description }} - {{ else if gt (len .Plain) 120 }} - {{ slicestr .Plain 0 120 | htmlUnescape }}... - {{ else }} - {{ .Plain | htmlUnescape }} - {{ end }} + {{ else }} + {{ .Plain | htmlUnescape | safeHTML | truncate 120 }} + {{ end }} </span> </div> </div> diff --git a/layouts/_default/rss.xml b/layouts/_default/rss.xml index 4acb190..1d7bc19 100644 --- a/layouts/_default/rss.xml +++ b/layouts/_default/rss.xml @@ -42,13 +42,11 @@ {{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}} <guid>{{ .Permalink }}</guid> <description> - {{ if isset .Params "description" }} + {{ if isset .Params "description" }} {{ .Description }} - {{ else if gt (len .Plain) 120 }} - {{ slicestr .Plain 0 120 | htmlUnescape }}... - {{ else }} - {{ .Plain | htmlUnescape }} - {{ end }} + {{ else }} + {{ .Plain | htmlUnescape | safeHTML | truncate 120 }} + {{ end }} </description> </item> {{ end -}} diff --git a/layouts/index.html b/layouts/index.html index d0db4a5..1bb144d 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -83,11 +83,9 @@ </div> <span class="description"> {{ if isset .Params "description" }} - {{ .Description }} - {{ else if gt (len .Plain) 120 }} - {{ slicestr .Plain 0 120 | htmlUnescape }}... + {{ .Description }} {{ else }} - {{ .Plain | htmlUnescape }} + {{ .Plain | htmlUnescape | safeHTML | truncate 120 }} {{ end }} </span> </div> |