Add record number display to mdbook

Original link: https://www.ixiqin.com/2023/07/25/%E7%BB%99-mdbook-%E5%A2%9E%E5%8A%A0%E5%A4%87%E6%A1%88%E5%8F%B7%E6%98%BE%E7%A4%BA/

0f0a26cef16e0d0eb89748745f259758.jpg

Since Gitbook has not been maintained for a long time, in order to ensure the continuous availability of the entire architecture, I had to migrate from Gitbook to mdbook.

When using mdbook, there is a problem that many of my e-book domain names are filed, and mdbook does not support external links in the directory like gitbook, so I need to add an external link to mdbook by myself.

Implementation ideas

Since there is no way to directly jump to external links in Markdown, a relatively simple and crude method is to add them directly in the template. It just so happens that mdbook explains the specific operation method in the document.

You just need to create a theme folder in the root directory of mdbook and generate an index.hbs file for rendering pages.

Next, you only need to add the code you need in the appropriate position (the ordered list after the toc below is manually added by me)

 <nav id="sidebar" class="sidebar" aria-label="Table of contents"> <div class="sidebar-scrollbox"> <ol class="chapter"> <li class="chapter-item expanded "><a href="https://beian.miit.gov.cn/" target="_blank">这里是你的备案号</a></li> </ol> </div> <div id="sidebar-resize-handle" class="sidebar-resize-handle"></div> </nav>

reference documents

https://github.com/rust-lang/mdBook/issues/1354

This article is reproduced from: https://www.ixiqin.com/2023/07/25/%E7%BB%99-mdbook-%E5%A2%9E%E5%8A%A0%E5%A4%87%E6%A1%88%E5%8F%B7%E6%98%BE%E7%A4%BA/
This site is only for collection, and the copyright belongs to the original author.