wpsharks / wp-kb-articles

KB Articles for WordPress; adds a new Custom Post Type.
http://wpkbarticles.com/
2 stars 1 forks source link

Automatic TOC Generation #9

Closed jaswrks closed 9 years ago

jaswrks commented 9 years ago

Eventually it would be nice if WP KB Articles could support an automatic Table of Contents generator that would be based on <h[0-9]> tags found in the article body.

2014-12-22_17-32-36

brucewrks commented 9 years ago

This would be something awesome to have in s2Clean, too!

jaswrks commented 9 years ago

This has been implemented. I also updated the YAML Front Matter article to include a new field that can be used to control this behavior (toc-enable:). There is also a new default config. option for this in the Dashboard with additional instructions.

cc @raamdev There's not much to this. Basically, you just add headers (either in raw HTML or with Markdown) and a TOC is generated automatically by the WPKBA plugin.

If you want to disable it globally you can do that from the Dashboard. Or, you can control it on a per-article basis (no matter what the global config. option is), by adding a YAML config. field: toc-enable: true|false in a specific article.

Of course, an article with no headings will already be bypassed on the TOC generation.

2015-01-19_03-02-03

2015-01-19_03-04-01

raamdev commented 9 years ago

Woohoo! Awesome! I love it.

I've created a new KB Article for this: Automatically Generating a Table of Contents (TOC)