hexo
hexo copied to clipboard
TOC plugin (in addition of the helper)
Feature request
Ok for the helper (https://hexo.io/docs/helpers#toc) https://github.com/hexojs/hexo/issues/408
but it would be cool to have a toc plugin too {% toc %}
so instead of having the helper on a template we will be able to manually add a toc on a per article basis without modifying the template or frontmatters.
Hi @noraj :wave:
I usually use this: https://github.com/bubkoo/hexo-toc
<!-- toc -->
Can you try and see if it works?
@tcrowe Check what I said in #3288
Maybe we could address this feature into a tag plugin which can be used as <!-- toc -->
or {% toc %}
.
See also https://github.com/theme-next/hexo-theme-next/issues/1529
I want to add a TOC in a page (Markdown content) but as @ptsteadman wrote this is not possible (https://github.com/hexojs/site/pull/118).
Using hexo-toc also doesn't work for me as it overwrites Hexo's native TOC helper: https://github.com/bubkoo/hexo-toc/issues/26 😢
Hexo needs to generate the toc after all the tag plugins have been rendered, as other tag plugins may also generate heading elements in them. For example:
## Heading
{% toc %}
{% note %}
## Heading
{% endnote %}
Making the toc a tag plugin would make the rendering order unsatisfiable.
Meanwhile I built my own hexo-insert-toc plugin which allows me to create a table of contents by placing a <!-- toc -->
in my Markdown files.
Closing as issue resolved