Files
discord.js/packages/website/src/components/HyperlinkedText.tsx
Suneet Tipirneni 1ed605eaa4 feat(website): add extends clauses, enum members and automatic -types links (#8270)
* feat(website): add extends clauses, enum members and automatic -types links

* chore: remove vscode settings

* refactor: remove util file
2022-07-12 22:42:32 +02:00

31 lines
653 B
TypeScript

import type { TokenDocumentation } from '~/util/parse.server';
export interface HyperlinkedTextProps {
tokens: TokenDocumentation[];
}
/**
* Constructs a hyperlinked html node based on token type references
*
* @param tokens An array of documentation tokens to construct the HTML
*
* @returns An array of JSX elements and string comprising the hyperlinked text
*/
export function HyperlinkedText({ tokens }: HyperlinkedTextProps) {
return (
<>
{tokens.map((token) => {
if (token.path) {
return (
<a key={token.text} href={token.path}>
{token.text}
</a>
);
}
return token.text;
})}
</>
);
}