hugolib: Consider summary in front matter for .Summary

Add the ability to have a `summary` page variable that overrides
the auto-generated summary.  Logic for obtaining summary becomes:

  * if summary divider is present in content, use the text above it
  * if summary variables is present in page metadata, use that
  * auto-generate summary from first _x_ words of the content

Fixes #5800
This commit is contained in:
Jim McDonald
2019-04-05 18:11:04 +01:00
committed by Bjørn Erik Pedersen
parent ebab291c0e
commit 3a62d54745
8 changed files with 115 additions and 15 deletions

View File

@@ -64,6 +64,8 @@ type pageMeta struct {
title string
linkTitle string
summary string
resourcePath string
weight int
@@ -361,6 +363,9 @@ func (pm *pageMeta) setMetadata(p *pageState, frontmatter map[string]interface{}
case "linktitle":
pm.linkTitle = cast.ToString(v)
pm.params[loki] = pm.linkTitle
case "summary":
pm.summary = cast.ToString(v)
pm.params[loki] = pm.summary
case "description":
pm.description = cast.ToString(v)
pm.params[loki] = pm.description