findNavigationItem(navigation: NavigationItem[], url, item: NavigationItem) { navigation.forEach(navigationChild => { if (navigationChild.url === url) { item = navigationChild; return; } if (navigationChild.children) { item = this.findNavigationItem(navigationChild.children, url, item); } }); return item; }
getSummaryMarkdown(renderer: RendererEvent) { const md = []; md.push(`* [Globals](globals.md)`); this.getNavigation(renderer.project).children.forEach(rootNavigation => { if (rootNavigation.children) { md.push(`* [${rootNavigation.title}](${rootNavigation.url})`); rootNavigation.children.forEach(item => { md.push(` * [${item.title}](${item.url})`); }); } }); return md.join('\n'); }
getNavObject(renderer: RendererEvent, docsRoot: string) { const projectUrls = [docsRoot + this.indexName.replace('.md', '')]; if (renderer.project.url === 'globals.md') { projectUrls.push(docsRoot + 'globals'); } const navObject = { ['Introduction']: projectUrls, }; this.getNavigation(renderer.project).children.forEach(rootNavigation => { navObject[rootNavigation.title] = rootNavigation.children.map(item => { return docsRoot + item.url.replace('.md', ''); }); }); return navObject; }
getNavObject(renderer: RendererEvent, docsRoot: string) { const navObject = {}; let url = ''; let navKey = ''; this.getNavigation(renderer.project).children.forEach(rootNavigation => { rootNavigation.children.map(item => { url = item.url.replace('.md', ''); navKey = url.substr(0, url.indexOf('/')); if (navKey !== undefined && navKey.length) { navKey = navKey[0].toUpperCase() + navKey.slice(1); } if (navObject[navKey] === undefined) { navObject[navKey] = []; } navObject[navKey].push(docsRoot + url); }); }); return navObject; }
getNavObject(renderer: RendererEvent, docsRoot: string = '') { const projectUrls = [docsRoot + this.indexName.replace('.md', '')]; if (renderer.project.url === 'globals.md') { projectUrls.push(docsRoot + 'globals'); } // const packageName = MarkdownPlugin.project.packageInfo.name; const navObject = []; // [{ title: packageName, children: projectUrls }] this.getNavigation(renderer.project).children.forEach(rootNavigation => { navObject.push({ title: rootNavigation.title, children: rootNavigation.children.map(item => { return docsRoot + item.url.replace('.md', ''); }), }); }); return navObject; }