From a69f5e0f486a1e754ba3ce14b8694cacde1a850b Mon Sep 17 00:00:00 2001 From: martyanov-av Date: Mon, 18 Nov 2024 14:24:08 +0300 Subject: [PATCH] fix: looking for a title by all tokens and not just even --- src/transform/plugins/links/index.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/transform/plugins/links/index.ts b/src/transform/plugins/links/index.ts index 092fb2c4..a2e0fb99 100644 --- a/src/transform/plugins/links/index.ts +++ b/src/transform/plugins/links/index.ts @@ -25,13 +25,14 @@ function getTitleFromTokens(tokens: Token[]) { while (i < tokens.length) { const token = tokens[i]; - if (token.type === 'heading_open') { - ({title = ''} = headingInfo(tokens, i)); + if (token?.type === 'heading_open') { + const info = headingInfo(tokens, i); + title = info?.title ?? ''; break; } - i += 2; + i += 1; } return title;