Open github-actions[bot] opened 11 months ago
fix any
https://github.com/LukaHarambasic/harambasic.de/blob/208d4831498a2d7d6f038f411070d949c87e77b7/src/lib/util/converter.server.ts#L96
} }}); }; } // todo maybe markdown file? interface HeadingNode extends Node { depth: number; children: { value: string }[]; } // todo maybe markdown file? function _remarkGenerateNestedToc() { console.log('------------------') return (tree: Node, file: VFile) => { const headings: { value: string, depth: number, slug: string }[] = [] visit(tree, 'heading', (node: HeadingNode) => { const value = node.children.reduce((text, child) => text + child.value, '') const slug = slugger(value) headings.push({ value, depth: node.depth, slug }) }); file.data.toc = _getNestedToc(headings) }; }; function _getNestedToc(markdownHeading: any): TocNode[] { let latestEntry: TocNode | null let latestParent: TocNode | null const markdownHeadingCopy = JSON.parse(JSON.stringify(markdownHeading)) if (markdownHeadingCopy.length <= 1) return markdownHeadingCopy // TODO fix any const entryDepth: number[] = markdownHeading.reduce((acc: number, item: any) => { return item.depth < acc ? item.depth : acc }, Number.POSITIVE_INFINITY) // TODO fix any return markdownHeadingCopy.reduce((result: any, entry: any) => { if (latestEntry && !latestEntry.children) { latestEntry.children = [] } const latestEntryDepth = latestEntry?.depth || 0 const latestEntryChildren = latestEntry?.children || [] const latestParentChildren = latestParent?.children || [] if (entry.depth === entryDepth) { entry.children = [] result.push(entry) latestParent = null } else if (entry.depth === latestEntryDepth + 1) { latestEntryChildren.push(entry) latestParent = latestEntry } else if (entry.depth === latestEntryDepth) { latestParentChildren.push(entry) } else { console.error('Unexpected Toc behaviour', entry) } latestEntry = entry return result }, []) }
50a1ec1160a6babcb65cae046260b8418ea4467e
fix any
https://github.com/LukaHarambasic/harambasic.de/blob/208d4831498a2d7d6f038f411070d949c87e77b7/src/lib/util/converter.server.ts#L96
50a1ec1160a6babcb65cae046260b8418ea4467e