(toc, tpl = '<ul class="app-sub-sidebar">{inner}</ul>')
| 85 | * @return {String} Rendered tree |
| 86 | */ |
| 87 | export 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 | |
| 103 | export function helper(className, content) { |
| 104 | return `<p class="${className}">${content.slice(5).trim()}</p>`; |
no outgoing calls
no test coverage detected
searching dependent graphs…