Possible to override jekyll-asciidoc's tocify?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Possible to override jekyll-asciidoc's tocify?

ctargett
My docs site is built with Jekyll and we use jekyll-asciidoc to convert our Asciidoc files. We used to have a JS-based TOC solution, but I've recently removed it in favor of using jekyll-asciidoc's tocify. It works well and we got rid of unnecessary JS.

Is it possible when using it to disable the TOC on a page-by-page basis, though? I have a couple of pages with just a couple sections and don't want a TOC on those. I can't find how in the docs and experiments like disabling it via an attribute have not removed it.

Any ideas?

Thanks in advance -
Cassandra
Reply | Threaded
Open this post in threaded view
|

Re: Possible to override jekyll-asciidoc's tocify?

ctargett
For anyone who might come across this later, I figured out a way to make the TOC conditionally appear by adding an "if" statement to the template:

  {% if page.show-toc != false %}
  <nav class="toc float-right justify-content-end">
    {{ page.document | tocify_asciidoc }}
  </nav>
  {% endif %}

In the front matter of the pages where I don't want the TOC to appear, I use ":page-show-toc: false", and the TOC section does not appear.
Reply | Threaded
Open this post in threaded view
|

Re: Possible to override jekyll-asciidoc's tocify?

mojavelinux
Administrator
Thanks for sharing this helpful tip!

If you'd like to see this added to the README for jekyll-asciidoc, feel free to send a PR and I'll merge it.

Best Regards,

-Dan

On Tue, Mar 31, 2020 at 4:12 PM ctargett [via Asciidoctor :: Discussion] <[hidden email]> wrote:
For anyone who might come across this later, I figured out a way to make the TOC conditionally appear by adding an "if" statement to the template:

  {% if page.show-toc != false %}
  <nav class="toc float-right justify-content-end">
    {{ page.document | tocify_asciidoc }}
  </nav>
  {% endif %}

In the front matter of the pages where I don't want the TOC to appear, I use ":page-show-toc: false", and the TOC section does not appear.


If you reply to this email, your message will be added to the discussion below:
https://discuss.asciidoctor.org/Possible-to-override-jekyll-asciidoc-s-tocify-tp7751p7813.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|

Re: Possible to override jekyll-asciidoc's tocify?

ctargett
I finally got around to creating a PR for this tip. Believe it or not, it's my first PR from a fork, so hopefully it went as well as GH makes it appear it did.
Reply | Threaded
Open this post in threaded view
|

Re: Possible to override jekyll-asciidoc's tocify?

mojavelinux
Administrator
Great work. Thanks!

Best Regards,

-Dan

On Thu, May 28, 2020 at 11:39 AM ctargett [via Asciidoctor :: Discussion] <[hidden email]> wrote:
I finally got around to creating a PR for this tip. Believe it or not, it's my first PR from a fork, so hopefully it went as well as GH makes it appear it did.


If you reply to this email, your message will be added to the discussion below:
https://discuss.asciidoctor.org/Possible-to-override-jekyll-asciidoc-s-tocify-tp7751p8065.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux