(path, type)
| 136 | } |
| 137 | |
| 138 | async _render(path, type) { |
| 139 | let html = await this._loadFile(path); |
| 140 | const { subMaxLevel, maxLevel } = this.config; |
| 141 | let tokens; |
| 142 | |
| 143 | switch (type) { |
| 144 | case 'sidebar': |
| 145 | html = |
| 146 | this.compiler.sidebar(html, maxLevel) + |
| 147 | `<script>window.__SUB_SIDEBAR__ = ${JSON.stringify( |
| 148 | this.compiler.subSidebar(subMaxLevel) |
| 149 | )}</script>`; |
| 150 | break; |
| 151 | case 'cover': |
| 152 | html = this.compiler.cover(html); |
| 153 | break; |
| 154 | case 'main': |
| 155 | tokens = await new Promise(r => { |
| 156 | prerenderEmbed( |
| 157 | { |
| 158 | fetch: url => this._loadFile(this._getPath(url)), |
| 159 | compiler: this.compiler, |
| 160 | raw: html, |
| 161 | }, |
| 162 | r |
| 163 | ); |
| 164 | }); |
| 165 | html = this.compiler.compile(tokens); |
| 166 | break; |
| 167 | case 'navbar': |
| 168 | case 'article': |
| 169 | default: |
| 170 | html = this.compiler.compile(html); |
| 171 | break; |
| 172 | } |
| 173 | |
| 174 | return html; |
| 175 | } |
| 176 | |
| 177 | async _loadFile(filePath) { |
| 178 | debug('docsify')(`load > ${filePath}`); |
no test coverage detected