* Compile sub sidebar * @param {Number} level Type of heading (h tag) * @returns {String} Sub-sidebar element
(level)
| 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); |
no test coverage detected