Skip to content

Commit

Permalink
since it is possible for node.children to be empty, I have updated th…
Browse files Browse the repository at this point in the history
…e code to make node.children optional so no errors occur (#1026)
  • Loading branch information
klai95 authored May 4, 2023
1 parent 0303ed2 commit 1776fca
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion frontend/src/components/Markdown/Markdown.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function getHeadersFromMarkdown(markdown: string): TOCHeader[] {
// Convert all H2 headings into TOCHeader objects.
return children
.filter((node): node is HeadingNode => node.tagName === TOC_HEADER_TAG)
.filter((node) => node.children[0].value !== undefined)
.filter((node) => node.children[0]?.value !== undefined)
.map<TOCHeader>((node) => ({
id: node.properties.id,
text: node.children[0].value,
Expand Down

0 comments on commit 1776fca

Please sign in to comment.