summaryrefslogtreecommitdiffstats
path: root/tpl/page
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2023-03-05 09:51:14 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2023-03-05 12:51:57 +0100
commitdf5608f8a0706c6519f50b5497e36c21b8e790be (patch)
treea5bd23a5f67ac1d9e9a7915bf94aead301d1c503 /tpl/page
parentf56ce01ae1a3e5b399410ea8876ebc7321204edd (diff)
Allow page.TableOfContents on self in shortcode
Fixes #10791
Diffstat (limited to 'tpl/page')
-rw-r--r--tpl/page/integration_test.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/tpl/page/integration_test.go b/tpl/page/integration_test.go
index 30a4885e0..74788377d 100644
--- a/tpl/page/integration_test.go
+++ b/tpl/page/integration_test.go
@@ -177,3 +177,35 @@ Shortcode in bundled page OK.
}
}
+
+// Issue 10791.
+func TestPageTableOfContentsInShortcode(t *testing.T) {
+ t.Parallel()
+
+ files := `
+-- config.toml --
+baseURL = 'http://example.com/'
+disableKinds = ["taxonomy", "term"]
+-- content/p1.md --
+---
+title: "P1"
+---
+{{< toc >}}
+
+# Heading 1
+-- layouts/shortcodes/toc.html --
+{{ page.TableOfContents }}
+-- layouts/_default/single.html --
+{{ .Content }}
+`
+
+ b := hugolib.NewIntegrationTestBuilder(
+ hugolib.IntegrationTestConfig{
+ T: t,
+ TxtarString: files,
+ },
+ ).Build()
+
+ b.AssertFileContent("public/p1/index.html", "<nav id=\"TableOfContents\"></nav> \n<h1 id=\"heading-1\">Heading 1</h1>")
+
+}