Make ContentWithoutSummary return Content when summary is fetched from front matter - hugo - [fork] hugo port for 9front
 (HTM) git clone git@git.drkhsh.at/hugo.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Submodules
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 8f2eac0195cf02f7edbcbce4b7e02768b12762fe
 (DIR) parent b570a5f1184fe275ad6fc04b82050ad8fce95651
 (HTM) Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
       Date:   Wed,  4 Sep 2024 19:07:59 +0200
       
       Make ContentWithoutSummary return Content when summary is fetched from front matter
       
       Fixes #12822
       
       Diffstat:
         M hugolib/page__content.go            |       9 +++++----
         M resources/page/page_markup_integra… |      14 +++++++++++++-
       
       2 files changed, 18 insertions(+), 5 deletions(-)
       ---
 (DIR) diff --git 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) {
 (DIR) diff --git 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) {