From 0221ddb39ee5d49387a779bc83af464e42fb3ebe Mon Sep 17 00:00:00 2001 From: Bjørn Erik Pedersen Date: Sat, 1 Jun 2024 10:27:10 +0200 Subject: content adapter: Handle separator in content.value Closes #12556 --- hugolib/page__per_output.go | 5 ++++- .../pagesfromgotmpl_integration_test.go | 26 ++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) (limited to 'hugolib') diff --git a/hugolib/page__per_output.go b/hugolib/page__per_output.go index 5b039b91b..6dffd18a5 100644 --- a/hugolib/page__per_output.go +++ b/hugolib/page__per_output.go @@ -307,7 +307,10 @@ func (pco *pageContentOutput) RenderString(ctx context.Context, args ...any) (te if pageparser.HasShortcode(contentToRender) { contentToRenderb := []byte(contentToRender) // String contains a shortcode. - parseInfo.itemsStep1, err = pageparser.ParseBytesMain(contentToRenderb, pageparser.Config{}) + parseInfo.itemsStep1, err = pageparser.ParseBytes(contentToRenderb, pageparser.Config{ + NoFrontMatter: true, + NoSummaryDivider: true, + }) if err != nil { return "", err } diff --git a/hugolib/pagesfromdata/pagesfromgotmpl_integration_test.go b/hugolib/pagesfromdata/pagesfromgotmpl_integration_test.go index cbb2da75c..f351cbb98 100644 --- a/hugolib/pagesfromdata/pagesfromgotmpl_integration_test.go +++ b/hugolib/pagesfromdata/pagesfromgotmpl_integration_test.go @@ -643,3 +643,29 @@ Footer: {{ range index site.Menus.footer }}{{ .Name }}|{{ end }}| "Footer: Footer|p2||", ) } + +func TestPagesFromGoTmplMore(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 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", + "

aaa

|content:

aaa

\n

bbb

", + ) +} -- cgit v1.2.3