Deprecated: Twig\Loader\FilesystemLoader::__construct(): Implicitly marking parameter $rootPath as nullable is deprecated, the explicit nullable type must be used instead in /home/nicedesi/docs.micro-sites.uk/wp-content/themes/webdev/vendor/twig/twig/src/Loader/FilesystemLoader.php on line 37

Deprecated: Twig\Environment::createTemplate(): Implicitly marking parameter $name as nullable is deprecated, the explicit nullable type must be used instead in /home/nicedesi/docs.micro-sites.uk/wp-content/themes/webdev/vendor/twig/twig/src/Environment.php on line 446

Deprecated: Twig\Node\Node::__construct(): Implicitly marking parameter $tag as nullable is deprecated, the explicit nullable type must be used instead in /home/nicedesi/docs.micro-sites.uk/wp-content/themes/webdev/vendor/twig/twig/src/Node/Node.php on line 39

Deprecated: Twig\Parser::addImportedSymbol(): Implicitly marking parameter $node as nullable is deprecated, the explicit nullable type must be used instead in /home/nicedesi/docs.micro-sites.uk/wp-content/themes/webdev/vendor/twig/twig/src/Parser.php on line 274

Deprecated: Twig\NodeVisitor\SafeAnalysisNodeVisitor::intersectSafe(): Implicitly marking parameter $a as nullable is deprecated, the explicit nullable type must be used instead in /home/nicedesi/docs.micro-sites.uk/wp-content/themes/webdev/vendor/twig/twig/src/NodeVisitor/SafeAnalysisNodeVisitor.php on line 137

Deprecated: Twig\NodeVisitor\SafeAnalysisNodeVisitor::intersectSafe(): Implicitly marking parameter $b as nullable is deprecated, the explicit nullable type must be used instead in /home/nicedesi/docs.micro-sites.uk/wp-content/themes/webdev/vendor/twig/twig/src/NodeVisitor/SafeAnalysisNodeVisitor.php on line 137

Deprecated: Twig\TokenStream::__construct(): Implicitly marking parameter $source as nullable is deprecated, the explicit nullable type must be used instead in /home/nicedesi/docs.micro-sites.uk/wp-content/themes/webdev/vendor/twig/twig/src/TokenStream.php on line 28

Deprecated: Twig\TokenStream::expect(): Implicitly marking parameter $message as nullable is deprecated, the explicit nullable type must be used instead in /home/nicedesi/docs.micro-sites.uk/wp-content/themes/webdev/vendor/twig/twig/src/TokenStream.php on line 71

Deprecated: Twig\Node\BlockNode::__construct(): Implicitly marking parameter $tag as nullable is deprecated, the explicit nullable type must be used instead in /home/nicedesi/docs.micro-sites.uk/wp-content/themes/webdev/vendor/twig/twig/src/Node/BlockNode.php on line 24

Deprecated: Twig\Node\Expression\ArrayExpression::addElement(): Implicitly marking parameter $key as nullable is deprecated, the explicit nullable type must be used instead in /home/nicedesi/docs.micro-sites.uk/wp-content/themes/webdev/vendor/twig/twig/src/Node/Expression/ArrayExpression.php on line 59

Deprecated: Twig\Template::displayBlock(): Implicitly marking parameter $templateContext as nullable is deprecated, the explicit nullable type must be used instead in /home/nicedesi/docs.micro-sites.uk/wp-content/themes/webdev/vendor/twig/twig/src/Template.php on line 162

Deprecated: Twig\Node\PrintNode::__construct(): Implicitly marking parameter $tag as nullable is deprecated, the explicit nullable type must be used instead in /home/nicedesi/docs.micro-sites.uk/wp-content/themes/webdev/vendor/twig/twig/src/Node/PrintNode.php on line 25

Deprecated: Twig\Node\IfNode::__construct(): Implicitly marking parameter $tag as nullable is deprecated, the explicit nullable type must be used instead in /home/nicedesi/docs.micro-sites.uk/wp-content/themes/webdev/vendor/twig/twig/src/Node/IfNode.php on line 24

Deprecated: Twig\Node\ForNode::__construct(): Implicitly marking parameter $tag as nullable is deprecated, the explicit nullable type must be used instead in /home/nicedesi/docs.micro-sites.uk/wp-content/themes/webdev/vendor/twig/twig/src/Node/ForNode.php on line 28

Deprecated: Twig\Node\ForLoopNode::__construct(): Implicitly marking parameter $tag as nullable is deprecated, the explicit nullable type must be used instead in /home/nicedesi/docs.micro-sites.uk/wp-content/themes/webdev/vendor/twig/twig/src/Node/ForLoopNode.php on line 23

Deprecated: Twig\Node\Expression\FilterExpression::__construct(): Implicitly marking parameter $tag as nullable is deprecated, the explicit nullable type must be used instead in /home/nicedesi/docs.micro-sites.uk/wp-content/themes/webdev/vendor/twig/twig/src/Node/Expression/FilterExpression.php on line 20

Deprecated: Twig\Node\BlockReferenceNode::__construct(): Implicitly marking parameter $tag as nullable is deprecated, the explicit nullable type must be used instead in /home/nicedesi/docs.micro-sites.uk/wp-content/themes/webdev/vendor/twig/twig/src/Node/BlockReferenceNode.php on line 24

Deprecated: Twig\Node\IncludeNode::__construct(): Implicitly marking parameter $tag as nullable is deprecated, the explicit nullable type must be used instead in /home/nicedesi/docs.micro-sites.uk/wp-content/themes/webdev/vendor/twig/twig/src/Node/IncludeNode.php on line 25

Deprecated: Twig\Node\SetNode::__construct(): Implicitly marking parameter $tag as nullable is deprecated, the explicit nullable type must be used instead in /home/nicedesi/docs.micro-sites.uk/wp-content/themes/webdev/vendor/twig/twig/src/Node/SetNode.php on line 24

Deprecated: Twig\Node\Expression\Filter\DefaultFilter::__construct(): Implicitly marking parameter $tag as nullable is deprecated, the explicit nullable type must be used instead in /home/nicedesi/docs.micro-sites.uk/wp-content/themes/webdev/vendor/twig/twig/src/Node/Expression/Filter/DefaultFilter.php on line 32
TOC – Code Bank
[ald_default calltag=true]

CODE BANK

a place to bank your code

TOC

Table of contents:

     <div class="tbl-container">
          <div class="tbl">
              <div id="table-of-contents"></div>
          </div>
      </div>

	document.addEventListener("DOMContentLoaded", function () {
		const content = document.querySelector(".blog-copy"); // Adjust selector to your blog content container
		const toc = document.getElementById("table-of-contents");

		const headings = content.querySelectorAll("h2, h3");
		if (!headings.length) return;

		const tocList = document.createElement("ul");

		headings.forEach((heading, index) => {
			if (!heading.id) {
				heading.id = "section-" + index;
			}

			const link = document.createElement("a");
			link.href = "#" + heading.id;
			link.textContent = heading.textContent;

			const listItem = document.createElement("li");

			// Create a span wrapper so you can inject the icon
			listItem.innerHTML = `${tocIcon} `;
			listItem.appendChild(link);

			// Indent h3
			if (heading.tagName.toLowerCase() === "h3") {
				listItem.style.marginLeft = "20px";
			}

			tocList.appendChild(listItem);
		});


		toc.innerHTML = "<h2>Table of Contents</h2>";
		toc.appendChild(tocList);
	});
.tbl-container {
  background-color: #f5f5f5;
padding:2rem;
margin-bottom: 1rem;
width:80%;
.tbl{

li {
   position: relative;
   margin: 1rem 0;
   @apply hover:text-secondary

 } 
   a {
       @apply text-primary;
     
        &:hover {
           @apply text-secondary;
        }
   }
}
}
Top