mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
refactor: remove banner
This commit is contained in:
@@ -2,7 +2,7 @@ import type { ApiFunction, ApiItem } from '@discordjs/api-extractor-model';
|
||||
import { ApiModel } from '@discordjs/api-extractor-model';
|
||||
import dynamic from 'next/dynamic';
|
||||
import { notFound } from 'next/navigation';
|
||||
import type { PropsWithChildren } from 'react';
|
||||
import { cache, type PropsWithChildren } from 'react';
|
||||
import { fetchModelJSON, fetchVersions } from '~/app/docAPI';
|
||||
// import { Banner } from '~/components/Banner';
|
||||
import { CmdKDialog } from '~/components/CmdK';
|
||||
@@ -35,14 +35,14 @@ export async function generateStaticParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
function serializeIntoSidebarItemData(item: ApiItem): SidebarSectionItemData {
|
||||
const serializeIntoSidebarItemData = cache((item: ApiItem) => {
|
||||
return {
|
||||
kind: item.kind,
|
||||
name: item.displayName,
|
||||
href: resolveItemURI(item),
|
||||
overloadIndex: 'overloadIndex' in item ? (item.overloadIndex as number) : undefined,
|
||||
};
|
||||
}
|
||||
} as SidebarSectionItemData;
|
||||
});
|
||||
|
||||
export default async function PackageLayout({ children, params }: PropsWithChildren<{ params: VersionRouteParams }>) {
|
||||
const modelJSON = await fetchModelJSON(params.package, params.version);
|
||||
@@ -81,7 +81,7 @@ export default async function PackageLayout({ children, params }: PropsWithChild
|
||||
<main className="mx-auto max-w-7xl px-4 lg:max-w-full">
|
||||
<Header />
|
||||
<div className="relative top-2.5 mx-auto max-w-7xl gap-6 lg:max-w-full lg:flex">
|
||||
<div className="lg:sticky lg:top-23 lg:h-[calc(100vh_-_145px)]">
|
||||
<div className="lg:sticky lg:top-23 lg:h-[calc(100vh_-_105px)]">
|
||||
<Nav members={members.map((member) => serializeIntoSidebarItemData(member))} versions={versions} />
|
||||
</div>
|
||||
|
||||
|
||||
@@ -11,15 +11,6 @@ export default function Page() {
|
||||
<div className="mx-auto min-h-screen min-w-xs flex flex-col gap-8 px-4 py-6 sm:w-md lg:px-6 lg:py-6">
|
||||
<h1 className="text-2xl font-semibold">Select a package:</h1>
|
||||
<div className="flex flex-col gap-4">
|
||||
{/* <a className={buttonVariants({ variant: 'secondary' })} href="https://old.discordjs.dev/#/docs/discord.js">
|
||||
<div className="flex grow flex-row place-content-between place-items-center gap-4">
|
||||
<div className="flex flex-row place-content-between place-items-center gap-4">
|
||||
<VscPackage size={25} />
|
||||
<h2 className="font-semibold">discord.js</h2>
|
||||
</div>
|
||||
<VscArrowRight size={20} />
|
||||
</div>
|
||||
</a> */}
|
||||
{PACKAGES.map((pkg, idx) => (
|
||||
<Link
|
||||
className={buttonVariants({ variant: 'secondary' })}
|
||||
@@ -31,14 +22,6 @@ export default function Page() {
|
||||
<VscPackage size={25} />
|
||||
<h2 className="font-semibold">{pkg}</h2>
|
||||
</div>
|
||||
{/* <Link href={`/docs/packages/${pkg}`}>
|
||||
<div
|
||||
className="bg-blurple focus:ring-width-2 flex h-6 transform-gpu cursor-pointer select-none appearance-none flex-row place-content-center place-items-center rounded border-0 px-2 text-xs font-semibold leading-none text-white outline-none focus:ring focus:ring-white active:translate-y-px"
|
||||
role="link"
|
||||
>
|
||||
Select version
|
||||
</div>
|
||||
</Link> */}
|
||||
<VscArrowRight size={20} />
|
||||
</div>
|
||||
</Link>
|
||||
|
||||
@@ -4,7 +4,6 @@ import Image from 'next/image';
|
||||
import Link from 'next/link';
|
||||
import vercelLogo from '~/assets/powered-by-vercel.svg';
|
||||
import workersLogo from '~/assets/powered-by-workers.png';
|
||||
// import { Banner } from '~/components/Banner';
|
||||
import { InstallButton } from '~/components/InstallButton';
|
||||
import { buttonVariants } from '~/styles/Button';
|
||||
import { DESCRIPTION } from '~/util/constants';
|
||||
@@ -12,7 +11,6 @@ import { DESCRIPTION } from '~/util/constants';
|
||||
export default function Page() {
|
||||
return (
|
||||
<div className="min-h-screen">
|
||||
{/* <Banner /> */}
|
||||
<div className="mx-auto max-w-6xl flex flex-col place-items-center gap-24 px-8 pb-16 pt-12 lg:min-h-[calc(100vh_-_40px)] lg:place-content-center lg:py-10">
|
||||
<div className="flex flex-col place-items-center gap-10 lg:flex-row lg:gap-6">
|
||||
<div className="flex flex-col place-items-center gap-10 text-center">
|
||||
@@ -22,9 +20,6 @@ export default function Page() {
|
||||
</h1>
|
||||
<p className="my-6 leading-normal text-neutral-700 dark:text-neutral-300">{DESCRIPTION}</p>
|
||||
<div className="flex flex-wrap place-content-center gap-4 md:flex-row">
|
||||
{/* <a className={buttonVariants()} href="https://old.discordjs.dev/#/docs" rel="noopener noreferrer">
|
||||
Docs
|
||||
</a> */}
|
||||
<Link className={buttonVariants()} href={'/docs' as Route}>
|
||||
Docs
|
||||
</Link>
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
import type { HTMLAttributes } from 'react';
|
||||
|
||||
export function Banner({ className, ...props }: HTMLAttributes<HTMLDivElement>) {
|
||||
return (
|
||||
<div className={`bg-blurple px-4 py-2 text-center text-sm text-white ${className}`} {...props}>
|
||||
You are reading the documentation for the <strong>next</strong> version of discord.js. Documentation for v13/v14+
|
||||
has been moved to{' '}
|
||||
<strong>
|
||||
<a href="https://old.discordjs.dev/#/docs" rel="external noopener noreferrer" target="_blank">
|
||||
old.discordjs.dev
|
||||
</a>
|
||||
</strong>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -16,16 +16,6 @@ export default function PackageSelect() {
|
||||
|
||||
const packageMenuItems = useMemo(
|
||||
() =>
|
||||
// <a href="https://old.discordjs.dev/#/docs/discord.js" key="discord.js">
|
||||
// <MenuItem
|
||||
// className="my-0.5 rounded bg-white p-3 text-sm outline-none active:bg-light-800 dark:bg-dark-600 hover:bg-light-700 focus:ring focus:ring-width-2 focus:ring-blurple dark:active:bg-dark-400 dark:hover:bg-dark-500"
|
||||
// id="discord-js"
|
||||
// onClick={() => packageMenu.setOpen(false)}
|
||||
// state={packageMenu}
|
||||
// >
|
||||
// discord.js
|
||||
// </MenuItem>
|
||||
// </a>,
|
||||
PACKAGES.map((pkg, idx) => (
|
||||
<Link href={`/docs/packages/${pkg}/main`} key={`${pkg}-${idx}`}>
|
||||
<MenuItem
|
||||
|
||||
@@ -29,19 +29,15 @@ export default async function middleware(request: NextRequest) {
|
||||
try {
|
||||
const skip = await get<boolean>('SKIP_PACKAGE_VERSION_SELECTION');
|
||||
if (skip) {
|
||||
const latestVersion = await fetchLatestVersion('core');
|
||||
return NextResponse.redirect(new URL(`/docs/packages/core/${latestVersion}`, request.url));
|
||||
const latestVersion = await fetchLatestVersion('discord.js');
|
||||
return NextResponse.redirect(new URL(`/docs/packages/discord.js/${latestVersion}`, request.url));
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
|
||||
/* if (request.nextUrl.pathname.includes('discord.js')) {
|
||||
return NextResponse.redirect('https://old.discordjs.dev/#/docs/discord.js');
|
||||
} */
|
||||
|
||||
if (PACKAGES.some((pkg) => request.nextUrl.pathname.includes(pkg))) {
|
||||
// eslint-disable-next-line prefer-named-capture-group
|
||||
const packageName = /\/docs\/packages\/([^/]+)\/.*/.exec(request.nextUrl.pathname)?.[1] ?? 'core';
|
||||
const packageName = /\/docs\/packages\/([^/]+)\/.*/.exec(request.nextUrl.pathname)?.[1] ?? 'discord.js';
|
||||
const latestVersion = await fetchLatestVersion(packageName);
|
||||
return NextResponse.redirect(
|
||||
new URL(request.nextUrl.pathname.replace('stable', latestVersion ?? 'main'), request.url),
|
||||
@@ -52,5 +48,5 @@ export default async function middleware(request: NextRequest) {
|
||||
}
|
||||
|
||||
export const config = {
|
||||
matcher: ['/docs', /* '/docs/packages/discord.js(.*)?',*/ '/docs/packages/:package/stable/:member*'],
|
||||
matcher: ['/docs', '/docs/packages/:package/stable/:member*'],
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user