mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
fix: extract text from link tags for descriptions (#8739)
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user