Files
discord.js/packages/website/src/components/HyperlinkedText.tsx
2022-09-01 20:50:16 +02:00

28 lines
594 B
TypeScript

import type { TokenDocumentation } from '@discordjs/api-extractor-utils';
import { Anchor, Text } from '@mantine/core';
import Link from 'next/link';
export function HyperlinkedText({ tokens }: { tokens: TokenDocumentation[] }) {
return (
<>
{tokens.map((token, idx) => {
if (token.path) {
return (
<Link key={idx} href={token.path} passHref prefetch={false}>
<Anchor component="a" inherit>
{token.text}
</Anchor>
</Link>
);
}
return (
<Text key={idx} span unstyled>
{token.text}
</Text>
);
})}
</>
);
}