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

Method _render

packages/docsify-server-renderer/index.js:138–175  ·  view source on GitHub ↗
(path, type)

Source from the content-addressed store, hash-verified

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}`);

Callers 1

renderToStringMethod · 0.95

Calls 6

_loadFileMethod · 0.95
_getPathMethod · 0.95
prerenderEmbedFunction · 0.90
sidebarMethod · 0.80
subSidebarMethod · 0.80
coverMethod · 0.80

Tested by

no test coverage detected