diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 63d6044..e7a5032 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -12,7 +12,7 @@ jobs: fail-fast: false matrix: php: [8.1] - statamic: [4.0.*, 5.0.*] + statamic: [4.6.*, 5.*] os: [ubuntu-latest] laravel: [10.*] testbench: [8.*] diff --git a/src/Tags/Toc.php b/src/Tags/Toc.php index 4468931..ab77445 100644 --- a/src/Tags/Toc.php +++ b/src/Tags/Toc.php @@ -26,6 +26,12 @@ class Toc extends Tags */ public function index() { + if ($this->params->get('when', true) === false) { + return []; + } + + // get the supported header-levels + // get the supported header-levels $depth = $this->params->int("depth", 3); $start = $this->params->get('from', "h1"); diff --git a/tests/Unit/RecursionTest.php b/tests/Unit/RecursionTest.php new file mode 100644 index 0000000..d0aa89b --- /dev/null +++ b/tests/Unit/RecursionTest.php @@ -0,0 +1,50 @@ +put('toc', \Goldnead\StatamicToc\Tags\Toc::class); + } + + /** @test */ + public function it_renders_toc_with_when_param() + { + $content = '