mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 17:13:31 +01:00
refactor(website): extract layouts and use more server components (#9027)
Closes https://github.com/discordjs/discord.js/issues/8920 Closes https://github.com/discordjs/discord.js/issues/8997
This commit is contained in:
42
apps/website/src/components/ExcerptText.tsx
Normal file
42
apps/website/src/components/ExcerptText.tsx
Normal file
@@ -0,0 +1,42 @@
|
||||
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;
|
||||
})}
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user