#mdbook #table #content #toc #pagetoc

bin+lib mdbook-pagetoc

A mdbook plugin that provides a table of contents for each page

10 releases

0.1.9 Jan 23, 2024
0.1.8 Dec 30, 2023
0.1.7 Mar 12, 2023
0.1.5 Sep 21, 2022
0.1.0 Apr 5, 2022

#394 in Text processing

Download history 125/week @ 2024-01-02 141/week @ 2024-01-09 128/week @ 2024-01-16 119/week @ 2024-01-23 148/week @ 2024-01-30 192/week @ 2024-02-06 201/week @ 2024-02-13 189/week @ 2024-02-20 273/week @ 2024-02-27 184/week @ 2024-03-05 196/week @ 2024-03-12 141/week @ 2024-03-19 75/week @ 2024-03-26 96/week @ 2024-04-02 150/week @ 2024-04-09 124/week @ 2024-04-16

459 downloads per month

MPL-2.0 license

17KB
174 lines

mdbook-pagetoc

A mdbook plugin that provides a table of contents for each page. Uses css/js from mdBook-pagetoc.

Show me

Sample image from mdBook-pagetoc:

Notes:

  • Only supports the html renderer.

  • On the first run of mdbook build, it creates three files index.hbs, pagetoc.css and pagetoc.js.

  • You can customize any of them after the first run.

Configuration:

  • Add to book.toml config:

    [preprocessor.pagetoc]
    [output.html]
    additional-css = ["theme/pagetoc.css"]
    additional-js  = ["theme/pagetoc.js"]
    
  • If using a custom index.hbs, the place marker <div class="sidetoc"><nav class="pagetoc"></nav></div> can be inserted manually inside the <main> tag. ie. Replace

    <main>
       {{{ content }}}
    </main>
    

    with:

    <main><div class="sidetoc"><nav class="pagetoc"></nav></div>
        {{{ content }}}
    </main>
    
  • If not customizing, you may want to add entries as appropriate to .gitignore to keep your repo clean:

    theme/index.hbs
    theme/pagetoc.css
    theme/pagetoc.js
    
  • Customization: To autohide when only single header, add this snippet to pagetoc.css:

    a[class^='pagetoc-H']:only-child {
      display: none;
    }
    

Acknowledgments

Alternative

Dependencies

~12–24MB
~327K SLoC