mdbook-pagetoc

Crates.iomdbook-pagetoc
lib.rsmdbook-pagetoc
version0.2.0
sourcesrc
created_at2022-04-05 17:09:53.136578
updated_at2024-04-29 22:50:34.833467
descriptionA mdbook plugin that provides a table of contents for each page.
homepagehttps://github.com/slowsage/mdbook-pagetoc
repositoryhttps://github.com/slowsage/mdbook-pagetoc
max_upload_size
id562696
size54,360
(slowsage)

documentation

https://github.com/slowsage/mdbook-pagetoc

README

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 two files 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"]
    
  • The place marker <div class="sidetoc"><nav class="pagetoc"></nav></div> will be inserted inside the <main> tag. ie. This replaces

    <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/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

Commit count: 22

cargo fmt