MCPcopy
hub / github.com/docsifyjs/docsify / subSidebar

Method subSidebar

src/core/render/compiler.js:306–327  ·  view source on GitHub ↗

* Compile sub sidebar * @param {Number} level Type of heading (h tag) * @returns {String} Sub-sidebar element

(level)

Source from the content-addressed store, hash-verified

304 * @returns {String} Sub-sidebar element
305 */
306 subSidebar(level) {
307 if (!level) {
308 this.toc = [];
309 return;
310 }
311
312 const currentPath = this.router.getCurrentPath();
313 const { cacheTree, toc } = this;
314
315 toc[0] && toc[0].ignoreAllSubs && toc.splice(0);
316 toc[0] && toc[0].level === 1 && toc.shift();
317
318 for (let i = 0; i < toc.length; i++) {
319 toc[i].ignoreSubHeading && toc.splice(i, 1) && i--;
320 }
321
322 const tree = cacheTree[currentPath] || genTree(toc, level);
323
324 cacheTree[currentPath] = tree;
325 this.toc = [];
326 return treeTpl(tree);
327 }
328
329 header(text, level) {
330 return this.heading(text, level);

Callers 2

_renderMethod · 0.80
_renderSidebarMethod · 0.80

Calls 2

genTreeFunction · 0.90
getCurrentPathMethod · 0.45

Tested by

no test coverage detected