Skip to content

Commit

Permalink
Fix string comparison for .Truncated page variable
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
anthonyfok committed Jan 20, 2015
1 parent a17c290 commit 02da495
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion hugolib/page.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (p *Page) setSummary() {
} else {
// If hugo defines 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.Truncated = len(p.Summary) != len(plain)
}
Expand Down

0 comments on commit 02da495

Please sign in to comment.