mirror of
https://github.com/discordjs/discord.js.git
synced 2024-08-21 01:34:43 +12:00
fix(website): link dapi-types to proper website (#9388)
This commit is contained in:
parent
83143178aa
commit
cac3c07729
2 changed files with 21 additions and 1 deletions
|
@ -2,6 +2,7 @@ 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';
|
||||
import { DISCORD_API_TYPES_DOCS_URL } from '~/util/constants';
|
||||
|
||||
export interface ExcerptTextProps {
|
||||
/**
|
||||
|
@ -20,8 +21,24 @@ export interface ExcerptTextProps {
|
|||
export function ExcerptText({ model, excerpt }: ExcerptTextProps) {
|
||||
return (
|
||||
<>
|
||||
{excerpt.spannedTokens.map((token) => {
|
||||
{excerpt.spannedTokens.map((token, idx) => {
|
||||
if (token.kind === ExcerptTokenKind.Reference) {
|
||||
const source = token.canonicalReference?.source;
|
||||
|
||||
if (source && 'packageName' in source && source.packageName === 'discord-api-types') {
|
||||
const meaning = token.canonicalReference.symbol?.meaning;
|
||||
const href =
|
||||
meaning === 'type'
|
||||
? `${DISCORD_API_TYPES_DOCS_URL}#${token.text}`
|
||||
: `${DISCORD_API_TYPES_DOCS_URL}/${meaning}/${token.text}`;
|
||||
|
||||
return (
|
||||
<a className="text-blurple" href={href} key={idx} rel="external noreferrer noopener" target="_blank">
|
||||
{token.text}
|
||||
</a>
|
||||
);
|
||||
}
|
||||
|
||||
const item = model.resolveDeclarationReference(token.canonicalReference!, model).resolvedApiItem;
|
||||
|
||||
if (!item) {
|
||||
|
|
|
@ -38,3 +38,6 @@ client.on('interactionCreate', async (interaction) => {
|
|||
});
|
||||
|
||||
await client.login(TOKEN);`;
|
||||
|
||||
export const DISCORD_API_TYPES_VERSION = 'v10';
|
||||
export const DISCORD_API_TYPES_DOCS_URL = `https://discord-api-types.dev/api/discord-api-types-${DISCORD_API_TYPES_VERSION}`;
|
||||
|
|
Loading…
Reference in a new issue