TOC Twig Filter
7 sites
Security covered
This project provides a Twig filter that integrates with the TOC API to render tables of contents. It allows you to automatically generate and display a table of contents based on the content's headings, with options to customize the depth of headers included.
Twig filter rendering tables of contents via TOC API.
Usage
{% set body = content.body|render|toc %}
{{ body.toc }}
{{ body.content }}
{# OR #}
{% set body = content.body|render|toc('full') %}
{{ body.toc }}
{{ body.content }}
{# OR #}
{% set toc_options = {
'header_min': 2,
'header_max': 4,
} %}
{% set body = content.body|render|toc(toc_options) %}
{{ body.toc }}
{{ body.content }}