(text)
| 253 | } |
| 254 | |
| 255 | _renderSidebar(text) { |
| 256 | const { maxLevel, subMaxLevel, loadSidebar, hideSidebar } = this.config; |
| 257 | |
| 258 | if (hideSidebar) { |
| 259 | // FIXME : better styling solution |
| 260 | [ |
| 261 | document.querySelector('aside.sidebar'), |
| 262 | document.querySelector('button.sidebar-toggle'), |
| 263 | ] |
| 264 | .filter(e => !!e) |
| 265 | .forEach(node => node.parentNode.removeChild(node)); |
| 266 | document.querySelector('section.content').style.right = 'unset'; |
| 267 | document.querySelector('section.content').style.left = 'unset'; |
| 268 | document.querySelector('section.content').style.position = 'relative'; |
| 269 | document.querySelector('section.content').style.width = '100%'; |
| 270 | return null; |
| 271 | } |
| 272 | |
| 273 | this._renderTo('.sidebar-nav', this.compiler.sidebar(text, maxLevel)); |
| 274 | const activeEl = getAndActive(this.router, '.sidebar-nav', true, true); |
| 275 | if (loadSidebar && activeEl) { |
| 276 | activeEl.parentNode.innerHTML += |
| 277 | this.compiler.subSidebar(subMaxLevel) || ''; |
| 278 | } else { |
| 279 | // Reset toc |
| 280 | this.compiler.subSidebar(); |
| 281 | } |
| 282 | |
| 283 | // Bind event |
| 284 | this._bindEventOnRendered(activeEl); |
| 285 | } |
| 286 | |
| 287 | _bindEventOnRendered(activeEl) { |
| 288 | const { autoHeader } = this.config; |
no test coverage detected