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

Method _renderCover

src/core/render/index.js:350–392  ·  view source on GitHub ↗
(text, coverOnly)

Source from the content-addressed store, hash-verified

348 }
349
350 _renderCover(text, coverOnly) {
351 const el = dom.getNode('.cover');
352
353 dom.toggleClass(
354 dom.getNode('main'),
355 coverOnly ? 'add' : 'remove',
356 'hidden'
357 );
358 if (!text) {
359 dom.toggleClass(el, 'remove', 'show');
360 return;
361 }
362
363 dom.toggleClass(el, 'add', 'show');
364
365 let html = this.coverIsHTML ? text : this.compiler.cover(text);
366
367 const m = html
368 .trim()
369 .match('<p><img.*?data-origin="(.*?)"[^a]+alt="(.*?)">([^<]*?)</p>$');
370
371 if (m) {
372 if (m[2] === 'color') {
373 el.style.background = m[1] + (m[3] || '');
374 } else {
375 let path = m[1];
376
377 dom.toggleClass(el, 'add', 'has-mask');
378 if (!isAbsolutePath(m[1])) {
379 path = getPath(this.router.getBasePath(), m[1]);
380 }
381
382 el.style.backgroundImage = `url(${path})`;
383 el.style.backgroundSize = 'cover';
384 el.style.backgroundPosition = 'center center';
385 }
386
387 html = html.replace(m[0], '');
388 }
389
390 this._renderTo('.cover-main', html);
391 sticky();
392 }
393
394 _updateRender() {
395 // Render name link

Callers 1

_fetchCoverMethod · 0.80

Calls 5

_renderToMethod · 0.95
getPathFunction · 0.90
stickyFunction · 0.90
coverMethod · 0.80
getBasePathMethod · 0.45

Tested by

no test coverage detected