mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
Closes https://github.com/discordjs/discord.js/issues/8920 Closes https://github.com/discordjs/discord.js/issues/8997
43 lines
1013 B
TypeScript
43 lines
1013 B
TypeScript
import type { ApiModel, Excerpt } from '@microsoft/api-extractor-model';
|
|
import { ExcerptTokenKind } from '@microsoft/api-extractor-model';
|
|
import { ItemLink } from './ItemLink';
|
|
import { resolveItemURI } from './documentation/util';
|
|
|
|
export interface ExcerptTextProps {
|
|
/**
|
|
* The tokens to render.
|
|
*/
|
|
excerpt: Excerpt;
|
|
/**
|
|
* The model to resolve item references from.
|
|
*/
|
|
model: ApiModel;
|
|
}
|
|
|
|
/**
|
|
* A component that renders excerpt tokens from an api item.
|
|
*/
|
|
export function ExcerptText({ model, excerpt }: ExcerptTextProps) {
|
|
return (
|
|
<>
|
|
{excerpt.spannedTokens.map((token) => {
|
|
if (token.kind === ExcerptTokenKind.Reference) {
|
|
const item = model.resolveDeclarationReference(token.canonicalReference!, model).resolvedApiItem;
|
|
|
|
if (!item) {
|
|
return token.text;
|
|
}
|
|
|
|
return (
|
|
<ItemLink className="text-blurple" itemURI={resolveItemURI(item)} key={item.containerKey}>
|
|
{token.text}
|
|
</ItemLink>
|
|
);
|
|
}
|
|
|
|
return token.text;
|
|
})}
|
|
</>
|
|
);
|
|
}
|