rust-lang / mdBook

Create book from markdown files. Like Gitbook but implemented in Rust

Home Page:https://rust-lang.github.io/mdBook/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

storage optimization with shared side-bar in the html

ljbrooks opened this issue · comments

I am using mdbook for manual pages, which is auto generated with 100K md files. This is becoming an issue as it would take 100G to 200G disk space and hours of mdbook build time, and I think the bottleneck is how the sidebar is handled.

I looked into the generate html file, it seems every html file is 14MB because the side bar is duplicated verbatim, is having all the MD files listed and it takes a lot of space. I wonder if mdbook can optimize this a bit by sharing the side-bar data in a shared file and let all the HTML files load it.

I am no expert on this, just a speculation based on my observation.

Maybe we can do this iframe trick.

But, how do you highlight the current page in the side bar?

I suppose we can do this without modifying the binary.

  1. Hand write a Table of Content and put it in /src, e.g. /src/toc.html.
  2. Remove the sidebar section in index.hbs, and replace it with an iframe, e.g.
     <iframe src="{{ path_to_root }}/toc.html" onload="this.before((this.contentDocument.body||this.contentDocument).children[0]);this.remove()"></iframe>