mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
refactor(website): remove unneccessary addPackageToModel function (#9983)
* types: fix links in @deprecated tags * Merge branch 'main' into fix/deprecated-links-d.ts * fix: searchIndices * refactor: apply review suggestions * refactor: remove addPackageToModel function * fix: event links in search index * fix: wrong overload condition
This commit is contained in:
@@ -13,7 +13,7 @@ import type {
|
||||
ApiVariable,
|
||||
ApiFunction,
|
||||
} from '@discordjs/api-extractor-model';
|
||||
import { ApiItemKind, ApiModel } from '@discordjs/api-extractor-model';
|
||||
import { ApiItemKind, ApiModel, ApiPackage } from '@discordjs/api-extractor-model';
|
||||
import { tryResolveSummaryText } from '@discordjs/scripts';
|
||||
import type { Metadata } from 'next';
|
||||
import { notFound } from 'next/navigation';
|
||||
@@ -24,7 +24,6 @@ import { TypeAlias } from '~/components/model/TypeAlias';
|
||||
import { Variable } from '~/components/model/Variable';
|
||||
import { Enum } from '~/components/model/enum/Enum';
|
||||
import { Function } from '~/components/model/function/Function';
|
||||
import { addPackageToModel } from '~/util/addPackageToModel';
|
||||
import { OVERLOAD_SEPARATOR } from '~/util/constants';
|
||||
import { fetchMember } from '~/util/fetchMember';
|
||||
import { findMember } from '~/util/model';
|
||||
@@ -44,7 +43,8 @@ async function fetchHeadMember({ package: packageName, version, item }: ItemRout
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const model = addPackageToModel(new ApiModel(), modelJSON);
|
||||
const model = new ApiModel();
|
||||
model.addMember(ApiPackage.loadFromJson(modelJSON));
|
||||
const pkg = model.tryGetPackageByName(packageName);
|
||||
const entry = pkg?.entryPoints[0];
|
||||
|
||||
@@ -129,7 +129,8 @@ export async function generateStaticParams({ params: { package: packageName, ver
|
||||
return [];
|
||||
}
|
||||
|
||||
const model = addPackageToModel(new ApiModel(), modelJSON);
|
||||
const model = new ApiModel();
|
||||
model.addMember(ApiPackage.loadFromJson(modelJSON));
|
||||
|
||||
const pkg = model.tryGetPackageByName(packageName);
|
||||
const entry = pkg?.entryPoints[0];
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { ApiFunction, ApiItem } from '@discordjs/api-extractor-model';
|
||||
import { ApiModel } from '@discordjs/api-extractor-model';
|
||||
import { ApiModel, ApiPackage } from '@discordjs/api-extractor-model';
|
||||
import dynamic from 'next/dynamic';
|
||||
import { notFound } from 'next/navigation';
|
||||
import type { PropsWithChildren } from 'react';
|
||||
@@ -9,7 +9,6 @@ import { Nav } from '~/components/Nav';
|
||||
import { Outline } from '~/components/Outline';
|
||||
import type { SidebarSectionItemData } from '~/components/Sidebar';
|
||||
import { resolveItemURI } from '~/components/documentation/util';
|
||||
import { addPackageToModel } from '~/util/addPackageToModel';
|
||||
import { N_RECENT_VERSIONS, PACKAGES } from '~/util/constants';
|
||||
import { Providers } from './providers';
|
||||
|
||||
@@ -57,7 +56,8 @@ export default async function PackageLayout({ children, params }: PropsWithChild
|
||||
notFound();
|
||||
}
|
||||
|
||||
const model = addPackageToModel(new ApiModel(), modelJSON);
|
||||
const model = new ApiModel();
|
||||
model.addMember(ApiPackage.loadFromJson(modelJSON));
|
||||
|
||||
const pkg = model.tryGetPackageByName(params.package);
|
||||
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
import { type ApiModel, ApiPackage } from '@discordjs/api-extractor-model';
|
||||
|
||||
export const addPackageToModel = (model: ApiModel, data: any) => {
|
||||
model.addMember(ApiPackage.loadFromJson(data));
|
||||
return model;
|
||||
};
|
||||
@@ -1,6 +1,5 @@
|
||||
import { ApiModel, ApiFunction } from '@discordjs/api-extractor-model';
|
||||
import { ApiModel, ApiFunction, ApiPackage } from '@discordjs/api-extractor-model';
|
||||
import { fetchModelJSON } from '~/app/docAPI';
|
||||
import { addPackageToModel } from './addPackageToModel';
|
||||
import { OVERLOAD_SEPARATOR, PACKAGES } from './constants';
|
||||
import { findMember, findMemberByKey } from './model';
|
||||
|
||||
@@ -21,7 +20,7 @@ export const fetchMember = async (packageName: string, branchName: string, item?
|
||||
return null;
|
||||
}
|
||||
|
||||
addPackageToModel(model, modelJSON);
|
||||
model.addMember(ApiPackage.loadFromJson(modelJSON));
|
||||
|
||||
const [memberName, overloadIndex] = decodeURIComponent(item).split(OVERLOAD_SEPARATOR);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user