From 264fe788eec87ccd26c161ad141c629b1d29f6aa Mon Sep 17 00:00:00 2001 From: Joe Mooring Date: Fri, 12 Apr 2024 09:54:22 -0700 Subject: [PATCH] Add missing example to TOC page Closes #2526 --- content/en/content-management/toc.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/content/en/content-management/toc.md b/content/en/content-management/toc.md index 441d5e808..6efa9e3cd 100644 --- a/content/en/content-management/toc.md +++ b/content/en/content-management/toc.md @@ -68,6 +68,17 @@ The following is an example of a very basic [single page template]: The following is a [partial template][partials] that adds slightly more logic for page-level control over your table of contents. It assumes you are using a `toc` field in your content's [front matter] that, unless specifically set to `false`, will add a TOC to any page with a [`WordCount`] greater than 400. This example also demonstrates how to use [conditionals] in your templating: +{{< code file=layouts/partials/toc.html >}} +{{ if and (gt .WordCount 400 ) (.Params.toc) }} + +{{ end }} +{{< /code >}} + {{% note %}} With the preceding example, even pages with > 400 words *and* `toc` not set to `false` will not render a table of contents if there are no headings in the page for the `.TableOfContents` method to pull from. {{% /note %}}