MCPcopy Index your code
hub / github.com/docsifyjs/docsify / _loadFile

Method _loadFile

packages/docsify-server-renderer/index.js:177–209  ·  view source on GitHub ↗
(filePath)

Source from the content-addressed store, hash-verified

175 }
176
177 async _loadFile(filePath) {
178 debug('docsify')(`load > ${filePath}`);
179 let content;
180 try {
181 if (isAbsolutePath(filePath)) {
182 const res = await fetch(filePath);
183 if (!res.ok) {
184 throw Error();
185 }
186
187 content = await res.text();
188 this.lock = 0;
189 } else {
190 content = await readFileSync(filePath, 'utf8');
191 this.lock = 0;
192 }
193
194 return content;
195 } catch (e) {
196 this.lock = this.lock || 0;
197 if (++this.lock > 10) {
198 this.lock = 0;
199 return;
200 }
201
202 const fileName = basename(filePath);
203 const result = await this._loadFile(
204 resolvePathname(`../${fileName}`, filePath)
205 );
206
207 return result;
208 }
209 }
210}
211
212Renderer.version = '__VERSION__';

Callers 1

_renderMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected