mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 03:23:29 +01:00
feat(DocsLink): Support overriding text (#9525)
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import { FiExternalLink } from '@react-icons/all-files/fi/FiExternalLink';
|
import { FiExternalLink } from '@react-icons/all-files/fi/FiExternalLink';
|
||||||
|
import type { PropsWithChildren } from 'react';
|
||||||
import { BASE_URL, BASE_URL_LEGACY, PACKAGES, VERSION } from '~/util/constants';
|
import { BASE_URL, BASE_URL_LEGACY, PACKAGES, VERSION } from '~/util/constants';
|
||||||
|
|
||||||
interface DocsLinkOptions {
|
interface DocsLinkOptions {
|
||||||
@@ -50,7 +51,8 @@ export function DocsLink({
|
|||||||
symbol,
|
symbol,
|
||||||
brackets,
|
brackets,
|
||||||
static: staticReference,
|
static: staticReference,
|
||||||
}: DocsLinkOptions) {
|
children,
|
||||||
|
}: PropsWithChildren<DocsLinkOptions>) {
|
||||||
// In the case of no type and no parent, this will default to the entry point of the respective documentation.
|
// In the case of no type and no parent, this will default to the entry point of the respective documentation.
|
||||||
let url = docs === PACKAGES[0] ? `${BASE_URL_LEGACY}/${VERSION}/general/welcome` : `${BASE_URL}/${docs}/stable`;
|
let url = docs === PACKAGES[0] ? `${BASE_URL_LEGACY}/${VERSION}/general/welcome` : `${BASE_URL}/${docs}/stable`;
|
||||||
let text = `${docs === PACKAGES[0] ? '' : '@discordjs/'}${docs}`;
|
let text = `${docs === PACKAGES[0] ? '' : '@discordjs/'}${docs}`;
|
||||||
@@ -77,7 +79,7 @@ export function DocsLink({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<a className="inline-flex flex-row place-items-center gap-1" href={url} rel="noopener noreferrer" target="_blank">
|
<a className="inline-flex flex-row place-items-center gap-1" href={url} rel="noopener noreferrer" target="_blank">
|
||||||
{text}
|
{children ?? text}
|
||||||
<FiExternalLink size={18} />
|
<FiExternalLink size={18} />
|
||||||
</a>
|
</a>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user