]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
Add test for ToC vs include
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 29 Mar 2023 09:00:40 +0000 (11:00 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 29 Mar 2023 15:49:01 +0000 (17:49 +0200)
See #10866

hugolib/page__fragments_test.go

index 4b17378d59493db71dc571bf3cd86e8bad35fd4e..cce006e9f9c96d4c789836f2c3a753c19abeb914 100644 (file)
@@ -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]|")
+
+}