We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix any
harambasic.de/src/lib/util/converter.server.ts
Line 96 in 208d483
} }}); }; } // 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
The text was updated successfully, but these errors were encountered:
No branches or pull requests
fix any
harambasic.de/src/lib/util/converter.server.ts
Line 96 in 208d483
50a1ec1160a6babcb65cae046260b8418ea4467e
The text was updated successfully, but these errors were encountered: