From 49b91315f7caf11e3974eb55a5c0463593091365 Mon Sep 17 00:00:00 2001 From: Suneet Tipirneni <77477100+suneettipirneni@users.noreply.github.com> Date: Wed, 12 Oct 2022 05:37:07 -0400 Subject: [PATCH] fix: extract text from link tags for descriptions (#8739) --- apps/website/src/util/summary.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/apps/website/src/util/summary.ts b/apps/website/src/util/summary.ts index b715caa88..7b2d1cc80 100644 --- a/apps/website/src/util/summary.ts +++ b/apps/website/src/util/summary.ts @@ -4,6 +4,7 @@ import type { DocCodeSpanJSON, DocPlainTextJSON, DocNodeContainerJSON, + DocLinkTagJSON, } from '@discordjs/api-extractor-utils'; export function tryResolveDescription(member: ApiItemJSON) { @@ -15,11 +16,23 @@ export function tryResolveDescription(member: ApiItemJSON) { let retVal = ''; - function recurseNodes(node: DocNodeJSON) { + function recurseNodes(node: DocNodeJSON, emitMarkdownLinks = false) { switch (node.kind) { case 'CodeSpan': retVal += (node as DocCodeSpanJSON).code; break; + case 'LinkTag': { + const { text, urlDestination } = node as DocLinkTagJSON; + + if (text && urlDestination && emitMarkdownLinks) { + retVal += `[${text}](${urlDestination})`; + } else { + retVal += text ?? urlDestination ?? ''; + } + + break; + } + case 'PlainText': retVal += (node as DocPlainTextJSON).text; break;