gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
73.52k stars 7.38k forks source link

content adapter: Handle <!--more--> separator in content.value #12556

Closed jmooring closed 1 month ago

jmooring commented 1 month ago

This may not be possible, in which case we should add a note to the content adapter documentation.

func TestFoo(t *testing.T) {
    t.Parallel()

    files := `
-- hugo.toml --
disableKinds = ['home','rss','section','sitemap','taxonomy','term']
[markup.goldmark.renderer]
unsafe = true
-- content/s1/_content.gotmpl --
{{ $page := dict
    "content" (dict "mediaType" "text/markdown" "value" "aaa <!--more--> bbb")
    "title" "p1"
    "path" "p1"
  }}
  {{ .AddPage $page }}
-- layouts/_default/single.html --
summary: {{ .Summary }}|content: {{ .Content}}
`

    b := hugolib.Test(t, files)

    b.AssertFileContent("public/s1/p1/index.html",
        "summary: aaa|content: <p>aaa bbb</p>",
    )
}

The file content assertion fails. Actual content is:

summary: aaa bbb|content: <p>aaa <!--more--> bbb</p>

Note that (a) the summary isn't correct and (b) the <--more--> separator is passed through to content.

Reference: https://discourse.gohugo.io/t/content-adapters-content-summary-not-works/50096/

github-actions[bot] commented 1 week ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.