hexo-toc icon indicating copy to clipboard operation
hexo-toc copied to clipboard

hexo-toc plugin conflicts with toc helper in EJS templates

Open bennycode opened this issue 3 years ago • 2 comments

In the EJS template of my posts, I am using Hexo's native TOC helper:

<%- toc(page.content) %>

And in some content of my pages, I am using the TOC placeholder of this plugin (hexo-toc):

<!-- toc -->

The TOC helper in my posts works fine when "hexo-toc" is not installed but if I install "hexo-toc" it renders TOCs in my Markdown files but also affects the rendering of my TOC helper. I noticed that the TOC rendered by my EJS template gets shown but the links are not working when "hexo-toc" is installed.

Here is my "hexo-toc" config:

"toc": {
  "class": "toc",
  "decodeEntities": false,
  "maxdepth": 2,
  "slugify": "transliteration"
}

My Hexo.js version is 5.2.0.

bennycode avatar Dec 20 '20 21:12 bennycode

@bubkoo can you help me getting your plugin to run on my website https://typescript.tv/?

bennycode avatar May 02 '22 19:05 bennycode

After some coding I found the problem... The slug generation is different. Hexo internally uses "slugize" from "hexo-util". I created a PR to allow this option: https://github.com/bubkoo/hexo-toc/pull/29

bennycode avatar May 03 '22 23:05 bennycode