mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
fix(website): remove several obsolete special handling of dtypes (#10898)
* fix(website): remove several obsolete special handling of dtypes * fix: reduce hardcoded places * chore: api-extractor.json setting mainEntryPointName
This commit is contained in:
@@ -17,24 +17,21 @@ export function EntryPointSelect({
|
||||
const { entryPoints: parsedEntrypoints } = parseDocsPathParams(params.item as string[] | undefined);
|
||||
|
||||
return (
|
||||
<Select
|
||||
aria-label="Select an entrypoint"
|
||||
defaultSelectedKey={parsedEntrypoints.length ? parsedEntrypoints.join('/') : 'global'}
|
||||
>
|
||||
<Select aria-label="Select an entrypoint" defaultSelectedKey={parsedEntrypoints.join('/')}>
|
||||
<SelectTrigger className="bg-[#f3f3f4] dark:bg-[#121214]" />
|
||||
<SelectList classNames={{ popover: 'bg-[#f3f3f4] dark:bg-[#28282d]' }} items={entryPoints}>
|
||||
{(item) => (
|
||||
<SelectOption
|
||||
className="dark:pressed:bg-[#313135] bg-[#f3f3f4] dark:bg-[#28282d] dark:hover:bg-[#313135]"
|
||||
href={`/docs/packages/${params.packageName}/${params.version}/${item.entryPoint}`}
|
||||
id={item.entryPoint || 'global'}
|
||||
key={item.entryPoint || 'global'}
|
||||
id={item.entryPoint}
|
||||
key={item.entryPoint}
|
||||
onHoverStart={() =>
|
||||
router.prefetch(`/docs/packages/${params.packageName}/${params.version}/${item.entryPoint}`)
|
||||
}
|
||||
textValue={item.entryPoint || 'global'}
|
||||
textValue={item.entryPoint}
|
||||
>
|
||||
{item.entryPoint || 'global'}
|
||||
{item.entryPoint}
|
||||
</SelectOption>
|
||||
)}
|
||||
</SelectList>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Cloudflare from 'cloudflare';
|
||||
import { NextResponse, type NextRequest } from 'next/server';
|
||||
import { PACKAGES } from './util/constants';
|
||||
import { DEFAULT_ENTRY_POINT, PACKAGES, PACKAGES_WITH_ENTRY_POINTS } from './util/constants';
|
||||
import { ENV } from './util/env';
|
||||
|
||||
const client = new Cloudflare({
|
||||
@@ -8,7 +8,12 @@ const client = new Cloudflare({
|
||||
});
|
||||
|
||||
async function fetchLatestVersion(packageName: string): Promise<string> {
|
||||
const hasEntryPoints = PACKAGES_WITH_ENTRY_POINTS.includes(packageName);
|
||||
if (ENV.IS_LOCAL_DEV) {
|
||||
if (hasEntryPoints) {
|
||||
return ['main', ...DEFAULT_ENTRY_POINT].join('/');
|
||||
}
|
||||
|
||||
return 'main';
|
||||
}
|
||||
|
||||
@@ -19,7 +24,7 @@ async function fetchLatestVersion(packageName: string): Promise<string> {
|
||||
params: [packageName],
|
||||
});
|
||||
|
||||
return (result[0]?.results as { version: string }[] | undefined)?.[0]?.version ?? 'main';
|
||||
return `${(result[0]?.results as { version: string }[] | undefined)?.[0]?.version ?? 'main'}${hasEntryPoints ? ['', ...DEFAULT_ENTRY_POINT].join('/') : ''}`;
|
||||
} catch {
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -16,5 +16,7 @@ export const PACKAGES = [
|
||||
|
||||
export const PACKAGES_WITH_ENTRY_POINTS = ['discord-api-types'];
|
||||
|
||||
export const DEFAULT_ENTRY_POINT = ['v10'];
|
||||
|
||||
export const DESCRIPTION =
|
||||
"discord.js is a powerful Node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.";
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { DEFAULT_ENTRY_POINT } from './constants';
|
||||
|
||||
export function parseDocsPathParams(item: string[] | undefined): {
|
||||
entryPoints: string[];
|
||||
foundItem: string | undefined;
|
||||
@@ -10,7 +12,7 @@ export function parseDocsPathParams(item: string[] | undefined): {
|
||||
const hasTypeMarker = lastElement?.includes('%3A');
|
||||
|
||||
return {
|
||||
entryPoints: hasTypeMarker ? item.slice(0, -1) : item,
|
||||
entryPoints: hasTypeMarker ? item.slice(0, -1) : lastElement?.length === 0 ? DEFAULT_ENTRY_POINT : item,
|
||||
foundItem: hasTypeMarker ? lastElement : undefined,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user