Fix .Truncated in manual summaries
authorbep <bjorn.erik.pedersen@gmail.com>
Sun, 10 May 2015 11:33:50 +0000 (13:33 +0200)
committerbep <bjorn.erik.pedersen@gmail.com>
Sun, 10 May 2015 11:34:02 +0000 (13:34 +0200)
Fixes #1119

hugolib/page.go

index 3ed12af6baa38051789aed770b4a7eb47870320b..56a9ff16a1d7f2fc090176c52c673bf01f8089f9 100644 (file)
@@ -172,10 +172,14 @@ func (p *Page) setSummary() {
        // rendered and ready in p.contentShortcodes
 
        if bytes.Contains(p.rawContent, helpers.SummaryDivider) {
-               // If user defines split:
-               // Split, replace shortcode tokens, then render
-               p.Truncated = true // by definition
-               header := bytes.Split(p.rawContent, helpers.SummaryDivider)[0]
+               sections := bytes.Split(p.rawContent, helpers.SummaryDivider)
+               header := sections[0]
+               p.Truncated = true
+               if len(sections[1]) < 20 {
+                       // only whitespace?
+                       p.Truncated = len(bytes.Trim(sections[1], " \n\r")) > 0
+               }
+
                renderedHeader := p.renderBytes(header)
                if len(p.contentShortCodes) > 0 {
                        tmpContentWithTokensReplaced, err :=