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

Function genTree

src/core/render/gen-tree.js:8–30  ·  view source on GitHub ↗
(toc, maxLevel)

Source from the content-addressed store, hash-verified

6 * @return {Array} Headlines
7 */
8export function genTree(toc, maxLevel) {
9 const headlines = [];
10 const last = {};
11
12 toc.forEach(headline => {
13 const level = headline.level || 1;
14 const len = level - 1;
15
16 if (level > maxLevel) {
17 return;
18 }
19
20 if (last[len]) {
21 last[len].children = (last[len].children || []).concat(headline);
22 } else {
23 headlines.push(headline);
24 }
25
26 last[level] = headline;
27 });
28
29 return headlines;
30}

Callers 2

sidebarMethod · 0.90
subSidebarMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…