Skip to content

.Page.Truncated sometimes returns an incorrect value with manual summaries #13967

@jmooring

Description

@jmooring

In the test below, the first and last assertion fail because the value of .Truncated is the opposite of what it should be.

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

	files := `
-- hugo.toml --
disableKinds = ['home','rss','section','sitemap','taxonomy','term']
-- layouts/all.html --
Title: {{ .Title }}|Summary: {{ .Summary }}|Truncated: {{ .Truncated }}|
-- content/p1.md --
---
title: p1
---
<!--more--> one two three
-- content/p2.md --
---
title: p2
---
one <!--more--> two three
-- content/p3.md --
---
title: p3
---
one two <!--more--> three
-- content/p4.md --
---
title: p4
---
one two three <!--more-->
`
	b := hugolib.Test(t, files)

	b.AssertFileContent("public/p1/index.html", `Title: p1|Summary: |Truncated: true|`) // fails
	b.AssertFileContent("public/p2/index.html", `Title: p2|Summary: <p>one</p>|Truncated: true|`)
	b.AssertFileContent("public/p3/index.html", `Title: p3|Summary: <p>one two</p>|Truncated: true|`)
	b.AssertFileContent("public/p4/index.html", `Title: p4|Summary: <p>one two three</p>|Truncated: false|`) // fails
}

Reference: https://discourse.gohugo.io/t/problem-with-the-truncated-method-returning-true-when-it-shouldnt/55861

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions