mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-29 22:29:56 +02:00
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:
committed by
Bjørn Erik Pedersen
parent
ebab291c0e
commit
3a62d54745
@@ -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
|
||||
|
Reference in New Issue
Block a user