Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TOC plugin (in addition of the helper) #3287

Closed
noraj opened this issue Oct 14, 2018 · 8 comments
Closed

TOC plugin (in addition of the helper) #3287

noraj opened this issue Oct 14, 2018 · 8 comments

Comments

@noraj
Copy link
Contributor

noraj commented Oct 14, 2018

Feature request

Ok for the helper (https://hexo.io/docs/helpers#toc) #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.

@tcrowe
Copy link
Contributor

tcrowe commented Oct 23, 2018

Hi @noraj 👋

I usually use this:
https://github.com/bubkoo/hexo-toc

<!-- toc -->

Can you try and see if it works?

@noraj
Copy link
Contributor Author

noraj commented Oct 23, 2018

@tcrowe Check what I said in #3288

@SukkaW
Copy link
Member

SukkaW commented Nov 17, 2019

Maybe we could address this feature into a tag plugin which can be used as <!-- toc --> or {% toc %}.

@stevenjoezhang
Copy link
Member

See also theme-next/hexo-theme-next#1529

@bennycode
Copy link

I want to add a TOC in a page (Markdown content) but as @ptsteadman wrote this is not possible (hexojs/site#118).

Using hexo-toc also doesn't work for me as it overwrites Hexo's native TOC helper: bubkoo/hexo-toc#26 😢

@stevenjoezhang
Copy link
Member

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.

@bennycode
Copy link

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.

@stevenjoezhang
Copy link
Member

Closing as issue resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants