diff options
-rw-r--r-- | hugolib/page__content.go | 9 | ||||
-rw-r--r-- | resources/page/page_markup_integration_test.go | 14 |
2 files changed, 18 insertions, 5 deletions
diff --git a/hugolib/page__content.go b/hugolib/page__content.go index cc93fe5d5..4ec91f7b5 100644 --- a/hugolib/page__content.go +++ b/hugolib/page__content.go @@ -504,7 +504,7 @@ type contentTableOfContents struct { } type contentSummary struct { - content string + content template.HTML contentWithoutSummary template.HTML summary page.Summary } @@ -612,9 +612,9 @@ func (c *cachedContentScope) contentRendered(ctx context.Context) (contentSummar Truncated: summarized.Truncated(), } result.contentWithoutSummary = template.HTML(summarized.ContentWithoutSummary()) - result.content = summarized.Content() + result.content = template.HTML(summarized.Content()) } else { - result.content = string(b) + result.content = template.HTML(string(b)) } if !c.pi.hasSummaryDivider && cp.po.p.m.pageConfig.Summary == "" { @@ -646,6 +646,7 @@ func (c *cachedContentScope) contentRendered(ctx context.Context) (contentSummar Text: helpers.BytesToHTML(html), Type: page.SummaryTypeFrontMatter, } + rs.Value.contentWithoutSummary = rs.Value.content } return rs, err @@ -879,7 +880,7 @@ func (c *cachedContentScope) Content(ctx context.Context) (template.HTML, error) if err != nil { return "", err } - return template.HTML(cr.content), nil + return cr.content, nil } func (c *cachedContentScope) ContentWithoutSummary(ctx context.Context) (template.HTML, error) { diff --git a/resources/page/page_markup_integration_test.go b/resources/page/page_markup_integration_test.go index fc3c6a569..010a9d729 100644 --- a/resources/page/page_markup_integration_test.go +++ b/resources/page/page_markup_integration_test.go @@ -171,7 +171,7 @@ includecontent: {{ hugo.Context.MarkupScope }}|{{ $p.Markup.Render.Content }}| ) } -func TestPageMarkupWithoutSummary(t *testing.T) { +func TestPageContentWithoutSummary(t *testing.T) { t.Parallel() files := ` @@ -195,6 +195,13 @@ This is some content about a summary and more. Another paragraph. Third paragraph. +-- content/p3.md -- +--- +title: "Post 3" +date: "2020-01-01" +summary: "This is summary in front matter." +--- +This is content. -- layouts/_default/single.html -- Single. Page.Summary: {{ .Summary }}| @@ -229,6 +236,11 @@ Summary Truncated: {{ .Truncated }}| "Summary Type: auto", "Summary Truncated: true", ) + + b.AssertFileContentExact("public/p3/index.html", + "Summary: This is summary in front matter.|", + "ContentWithoutSummary: <p>This is content.</p>\n|", + ) } func TestPageMarkupWithoutSummaryRST(t *testing.T) { |