Skip to content

Commit 41755dc

Browse files
committed
fix: toc error caused by empty heading
1 parent 6739488 commit 41755dc

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/bytemd/src/toc.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
2222
hast.children
2323
.filter((v): v is Element => v.type === 'element')
24-
.forEach((child, index) => {
24+
.forEach(({ tagName, children }, index) => {
2525
for (let i = 6; i > 0; i--) {
26-
if (child.tagName === 'h' + i) {
26+
if (tagName === 'h' + i && children[0]) {
2727
minLevel = Math.min(minLevel, i);
2828
items.push({
2929
level: i,
30-
text: child.children[0].value as string, // TODO:
30+
text: children[0].value as string, // TODO: complicated children
3131
});
3232
3333
// console.log(currentBlockIndex, index);

0 commit comments

Comments
 (0)