mirror of
https://github.com/gohugoio/hugo.git
synced 2025-05-01 10:37:39 +00:00
Fix string comparison for .Truncated page variable
Instead of `strings.TrimSpace()`, use `strings.Join(strings.Fields(s), " ")` to collapse all whitespaces into single spaces, in order to match the behaviour of helpers.TruncateWordsToWholeSentence(), in order to detect non-truncated content correctly.
This commit is contained in:
parent
a17c290a33
commit
02da49597d
1 changed files with 1 additions and 1 deletions
|
@ -169,7 +169,7 @@ func (p *Page) setSummary() {
|
||||||
} else {
|
} else {
|
||||||
// If hugo defines split:
|
// If hugo defines split:
|
||||||
// render, strip html, then split
|
// render, strip html, then split
|
||||||
plain := strings.TrimSpace(p.Plain())
|
plain := strings.Join(strings.Fields(p.Plain()), " ")
|
||||||
p.Summary = helpers.BytesToHTML([]byte(helpers.TruncateWordsToWholeSentence(plain, helpers.SummaryLength)))
|
p.Summary = helpers.BytesToHTML([]byte(helpers.TruncateWordsToWholeSentence(plain, helpers.SummaryLength)))
|
||||||
p.Truncated = len(p.Summary) != len(plain)
|
p.Truncated = len(p.Summary) != len(plain)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue