Dynamically generate the table of contents from $Content
Automatically generate the table of contents from the Content of a page or, more generally, from any HTML field.
This module can be used without the CMS.
composer require entidi/silverstripe-autotoc
Manual installation is probably possible but not really tested.
Basically it boils down to the following commands:
composer update vendor/bin/phpunit