|
14 | 14 | package page_test
|
15 | 15 |
|
16 | 16 | import (
|
| 17 | + "strconv" |
| 18 | + "strings" |
17 | 19 | "testing"
|
18 | 20 |
|
19 | 21 | "github.com/gohugoio/hugo/hugolib"
|
@@ -347,3 +349,74 @@ Summary Truncated: {{ .Truncated }}|
|
347 | 349 | "Summary: <div class=\"paragraph\">\n<p>This is summary.</p>\n</div>|\nSummary Type: manual|\nSummary Truncated: true|",
|
348 | 350 | )
|
349 | 351 | }
|
| 352 | + |
| 353 | +func TestIssue13967(t *testing.T) { |
| 354 | + t.Parallel() |
| 355 | + |
| 356 | + files := ` |
| 357 | +-- hugo.toml -- |
| 358 | +disableKinds = ['home','rss','section','sitemap','taxonomy','term'] |
| 359 | +-- layouts/all.html -- |
| 360 | +Title: {{ .Title }}|Summary: {{ .Summary }}|Truncated: {{ .Truncated }}| |
| 361 | +-- content/p1.md -- |
| 362 | +--- |
| 363 | +title: p1 |
| 364 | +--- |
| 365 | +<!--more--> one two three |
| 366 | +-- content/p2.md -- |
| 367 | +--- |
| 368 | +title: p2 |
| 369 | +--- |
| 370 | +one <!--more--> two three |
| 371 | +-- content/p3.md -- |
| 372 | +--- |
| 373 | +title: p3 |
| 374 | +--- |
| 375 | +one two <!--more--> three |
| 376 | +-- content/p4.md -- |
| 377 | +--- |
| 378 | +title: p4 |
| 379 | +--- |
| 380 | +one two three <!--more--> |
| 381 | +` |
| 382 | + b := hugolib.Test(t, files) |
| 383 | + |
| 384 | + b.AssertFileContent("public/p1/index.html", `Title: p1|Summary: |Truncated: true|`) |
| 385 | + b.AssertFileContent("public/p2/index.html", `Title: p2|Summary: <p>one</p>|Truncated: true|`) |
| 386 | + b.AssertFileContent("public/p3/index.html", `Title: p3|Summary: <p>one two</p>|Truncated: true|`) |
| 387 | + b.AssertFileContent("public/p4/index.html", `Title: p4|Summary: <p>one two three</p>|Truncated: false|`) |
| 388 | +} |
| 389 | + |
| 390 | +func TestIssue13968(t *testing.T) { |
| 391 | + t.Parallel() |
| 392 | + |
| 393 | + files := ` |
| 394 | +-- hugo.toml -- |
| 395 | +disableKinds = ['page','rss','section','sitemap','taxonomy','term'] |
| 396 | +summaryLength = SUMMARY_LENGTH |
| 397 | +-- layouts/all.html -- |
| 398 | +Title: {{ .Title }}|Summary: {{ .Summary }}|Truncated: {{ .Truncated }}| |
| 399 | +-- content/_index.md -- |
| 400 | +--- |
| 401 | +title: home |
| 402 | +--- |
| 403 | +one two three |
| 404 | +` |
| 405 | + |
| 406 | + tests := []struct { |
| 407 | + summaryLength int |
| 408 | + want string |
| 409 | + }{ |
| 410 | + {0, "Title: home|Summary: |Truncated: true|"}, |
| 411 | + {1, "Title: home|Summary: <p>one two three</p>|Truncated: false|"}, |
| 412 | + {2, "Title: home|Summary: <p>one two three</p>|Truncated: false|"}, |
| 413 | + {3, "Title: home|Summary: <p>one two three</p>|Truncated: false|"}, |
| 414 | + {4, "Title: home|Summary: <p>one two three</p>|Truncated: false|"}, |
| 415 | + } |
| 416 | + |
| 417 | + for _, tt := range tests { |
| 418 | + f := strings.ReplaceAll(files, "SUMMARY_LENGTH", strconv.Itoa(tt.summaryLength)) |
| 419 | + b := hugolib.Test(t, f) |
| 420 | + b.AssertFileContent("public/index.html", tt.want) |
| 421 | + } |
| 422 | +} |
0 commit comments