summaryrefslogtreecommitdiffstats
path: root/hugolib
diff options
context:
space:
mode:
authorBrendan Roy <br3ndanr@gmail.com>2017-09-29 17:04:55 +1000
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-09-29 09:04:55 +0200
commit8717a60cc030f4310c1779c0cdd51db37ad636cd (patch)
treefeb0ee781117c22649dceebe24a29db59c5957fd /hugolib
parent2818878994e906c292cbe00cb2a83f1531a21f32 (diff)
Change SummaryLength to be configurable (#3924)
Move SummaryLength into the ContentSpec struct and refactor the relevant summary functions to be methods of ContentSpec. The new summaryLength struct member is configurable by the summaryLength config value, and the default remains 70. Also updates hugolib/page to use the refactored methods. Resolves #3734
Diffstat (limited to 'hugolib')
-rw-r--r--hugolib/config.go1
-rw-r--r--hugolib/page.go4
2 files changed, 3 insertions, 2 deletions
diff --git a/hugolib/config.go b/hugolib/config.go
index 2406ba771..d0ade018f 100644
--- a/hugolib/config.go
+++ b/hugolib/config.go
@@ -135,6 +135,7 @@ func loadDefaultSettingsFor(v *viper.Viper) error {
v.SetDefault("newContentEditor", "")
v.SetDefault("paginate", 10)
v.SetDefault("paginatePath", "page")
+ v.SetDefault("summaryLength", 70)
v.SetDefault("blackfriday", c.NewBlackfriday())
v.SetDefault("rSSUri", "index.xml")
v.SetDefault("rssLimit", -1)
diff --git a/hugolib/page.go b/hugolib/page.go
index d5c444ed6..12bdf312b 100644
--- a/hugolib/page.go
+++ b/hugolib/page.go
@@ -677,9 +677,9 @@ func (p *Page) setAutoSummary() error {
var summary string
var truncated bool
if p.isCJKLanguage {
- summary, truncated = helpers.TruncateWordsByRune(p.PlainWords(), helpers.SummaryLength)
+ summary, truncated = p.s.ContentSpec.TruncateWordsByRune(p.PlainWords())
} else {
- summary, truncated = helpers.TruncateWordsToWholeSentence(p.Plain(), helpers.SummaryLength)
+ summary, truncated = p.s.ContentSpec.TruncateWordsToWholeSentence(p.Plain())
}
p.Summary = template.HTML(summary)
p.Truncated = truncated