Hide tocbot block if empty

Created on 12 January 2025, 3 months ago

First of all: thanks for creating this module! It offers a very sophisticated solution to have a nice table of content block. Much appreciated!

One thing I noticed while working with Tocbot:

When the number set in "minActivate (number)" is not reached, the table of content is not generated (which is the desired outcome), but the block is still placed, containing an empty div:

<div class="js-toc-block"></div>

IMO it would be better, if the block would not appear at all if the minimal number to generate the table of content is not reached, mainly for two reasons:

  • If you set a block title for the Tocbot block, the title still appears even if the table of content is not generated
  • If you have a theme that hides an empty region and place the block in that region as the only element, the Tocbot block is still rendered, and with it that region (even if the region appears to have no content)
🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇨🇭Switzerland maenjuel

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024