fix(website): link dapi-types to proper website (#9388)

This commit is contained in:
Suneet Tipirneni 2023-04-14 14:53:57 -04:00 committed by GitHub
parent 83143178aa
commit cac3c07729
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View file

@ -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) {

View file

@ -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}`;