mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-19 21:13:30 +01:00
fix: extract text from link tags for descriptions (#8739)
This commit is contained in:
@@ -4,6 +4,7 @@ import type {
|
|||||||
DocCodeSpanJSON,
|
DocCodeSpanJSON,
|
||||||
DocPlainTextJSON,
|
DocPlainTextJSON,
|
||||||
DocNodeContainerJSON,
|
DocNodeContainerJSON,
|
||||||
|
DocLinkTagJSON,
|
||||||
} from '@discordjs/api-extractor-utils';
|
} from '@discordjs/api-extractor-utils';
|
||||||
|
|
||||||
export function tryResolveDescription(member: ApiItemJSON) {
|
export function tryResolveDescription(member: ApiItemJSON) {
|
||||||
@@ -15,11 +16,23 @@ export function tryResolveDescription(member: ApiItemJSON) {
|
|||||||
|
|
||||||
let retVal = '';
|
let retVal = '';
|
||||||
|
|
||||||
function recurseNodes(node: DocNodeJSON) {
|
function recurseNodes(node: DocNodeJSON, emitMarkdownLinks = false) {
|
||||||
switch (node.kind) {
|
switch (node.kind) {
|
||||||
case 'CodeSpan':
|
case 'CodeSpan':
|
||||||
retVal += (node as DocCodeSpanJSON).code;
|
retVal += (node as DocCodeSpanJSON).code;
|
||||||
break;
|
break;
|
||||||
|
case 'LinkTag': {
|
||||||
|
const { text, urlDestination } = node as DocLinkTagJSON;
|
||||||
|
|
||||||
|
if (text && urlDestination && emitMarkdownLinks) {
|
||||||
|
retVal += `[${text}](${urlDestination})`;
|
||||||
|
} else {
|
||||||
|
retVal += text ?? urlDestination ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case 'PlainText':
|
case 'PlainText':
|
||||||
retVal += (node as DocPlainTextJSON).text;
|
retVal += (node as DocPlainTextJSON).text;
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user