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

Function tree

src/core/render/tpl.js:87–101  ·  view source on GitHub ↗
(toc, tpl = '<ul class="app-sub-sidebar">{inner}</ul>')

Source from the content-addressed store, hash-verified

85 * @return {String} Rendered tree
86 */
87export function tree(toc, tpl = '<ul class="app-sub-sidebar">{inner}</ul>') {
88 if (!toc || !toc.length) {
89 return '';
90 }
91
92 let innerHTML = '';
93 toc.forEach(node => {
94 const title = node.title.replace(/(<([^>]+)>)/g, '');
95 innerHTML += `<li><a class="section-link" href="${node.slug}" title="${title}">${node.title}</a></li>`;
96 if (node.children) {
97 innerHTML += tree(node.children, tpl);
98 }
99 });
100 return tpl.replace('{inner}', innerHTML);
101}
102
103export function helper(className, content) {
104 return `<p class="${className}">${content.slice(5).trim()}</p>`;

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…