Add test for ToC vs include - hugo - [fork] hugo port for 9front
HTML git clone git@git.drkhsh.at/hugo.git
DIR Log
DIR Files
DIR Refs
DIR Submodules
DIR README
DIR LICENSE
---
DIR commit 5748133d507044857730d61591c2ba348ee6db6f
DIR parent 05c095a0e66f86cb31202442c7a1a54a348a1186
HTML Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Date: Wed, 29 Mar 2023 11:00:40 +0200
Add test for ToC vs include
See #10866
Diffstat:
M hugolib/page__fragments_test.go | 43 ++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+), 0 deletions(-)
---
DIR diff --git a/hugolib/page__fragments_test.go b/hugolib/page__fragments_test.go
@@ -67,3 +67,46 @@ Fragments : {{ $p1.Fragments.Identifiers }}
b.AssertFileContent("public/en/p1/index.json", "ToC: <nav id=\"TableOfContents\">\n <ul>\n <li><a href=\"#heading-1-fr\">Heading 1 FR</a></li>\n </ul>\n</nav>\nFragments : [heading-1-fr]")
}
+
+// Issue #10866
+func TestTableOfContentsWithIncludedMarkdownFile(t *testing.T) {
+ files := `
+-- hugo.toml --
+baseURL = "https://example.com"
+disableKinds = ["taxonomy", "term", "home"]
+-- content/p1.md --
+---
+title: "P1"
+---
+
+## Heading P1 1
+{{% include "p2" %}}
+
+-- content/p2.md --
+---
+title: "P2"
+---
+
+### Heading P2 1
+### Heading P2 2
+
+-- layouts/shortcodes/include.html --
+{{ with site.GetPage (.Get 0) }}{{ .RawContent }}{{ end }}
+-- layouts/_default/single.html --
+Fragments: {{ .Fragments.Identifiers }}|
+
+
+
+`
+
+ b := NewIntegrationTestBuilder(
+ IntegrationTestConfig{
+ TxtarString: files,
+ T: t,
+ },
+ ).Build()
+
+ b.AssertFileContent("public/p1/index.html", "Fragments: [heading-p1-1 heading-p2-1 heading-p2-2]|")
+ b.AssertFileContent("public/p2/index.html", "Fragments: [heading-p2-1 heading-p2-2]|")
+
+}