mcbSolutions / Pico-Plugins

Plugins for Pico - Pico is a stupidly simple, blazing fast, flat file CMS.
MIT License
12 stars 8 forks source link

Make TOC optional #8

Open bernd-wechner opened 3 years ago

bernd-wechner commented 3 years ago

I find that, having installed the plugin, on some pages I want a TOC on others not. It's easy enough to wrap all the twig template elements in a conditional:

  {% if meta.TOC %}
    <link rel="stylesheet" href="{{ plugins_url }}/mcb_TableOfContent/style.css">
  {% endif %}

  {% if meta.TOC %}{{ mcb_toc_top | raw }}{% endif %}

  {% if meta.TOC %}{{ mcb_toc | raw }}{% endif %}

But alas the PHP part of the plugin still ends up putting the text of mcb_toc_top_txt after each header. This should ideally not happen if a page doesn't want a TOC of course.