mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-15 19:13:31 +01:00
fix(website): link dapi-types to proper website (#9388)
This commit is contained in:
@@ -2,6 +2,7 @@ import type { ApiModel, Excerpt } from '@microsoft/api-extractor-model';
|
|||||||
import { ExcerptTokenKind } from '@microsoft/api-extractor-model';
|
import { ExcerptTokenKind } from '@microsoft/api-extractor-model';
|
||||||
import { ItemLink } from './ItemLink';
|
import { ItemLink } from './ItemLink';
|
||||||
import { resolveItemURI } from './documentation/util';
|
import { resolveItemURI } from './documentation/util';
|
||||||
|
import { DISCORD_API_TYPES_DOCS_URL } from '~/util/constants';
|
||||||
|
|
||||||
export interface ExcerptTextProps {
|
export interface ExcerptTextProps {
|
||||||
/**
|
/**
|
||||||
@@ -20,8 +21,24 @@ export interface ExcerptTextProps {
|
|||||||
export function ExcerptText({ model, excerpt }: ExcerptTextProps) {
|
export function ExcerptText({ model, excerpt }: ExcerptTextProps) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{excerpt.spannedTokens.map((token) => {
|
{excerpt.spannedTokens.map((token, idx) => {
|
||||||
if (token.kind === ExcerptTokenKind.Reference) {
|
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;
|
const item = model.resolveDeclarationReference(token.canonicalReference!, model).resolvedApiItem;
|
||||||
|
|
||||||
if (!item) {
|
if (!item) {
|
||||||
|
|||||||
@@ -38,3 +38,6 @@ client.on('interactionCreate', async (interaction) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
await client.login(TOKEN);`;
|
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}`;
|
||||||
|
|||||||
Reference in New Issue
Block a user