mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-18 12:33:30 +01:00
refactor: change url scheme
This commit is contained in:
@@ -2,9 +2,9 @@ import { NextResponse } from 'next/server';
|
|||||||
import type { NextRequest } from 'next/server';
|
import type { NextRequest } from 'next/server';
|
||||||
|
|
||||||
export default function middleware(request: NextRequest) {
|
export default function middleware(request: NextRequest) {
|
||||||
return NextResponse.redirect(new URL('/docs/main/packages/builders', request.url));
|
return NextResponse.redirect(new URL('/docs/packages/builders/main', request.url));
|
||||||
}
|
}
|
||||||
|
|
||||||
export const config = {
|
export const config = {
|
||||||
matcher: ['/docs', '/docs/:branch'],
|
matcher: ['/docs'],
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ export const getStaticPaths: GetStaticPaths = async () => {
|
|||||||
const pkg = findPackage(model, packageName);
|
const pkg = findPackage(model, packageName);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
{ params: { slug: ['main', 'packages', packageName] } },
|
{ params: { slug: ['packages', packageName, 'main'] } },
|
||||||
...getMembers(pkg!)
|
...getMembers(pkg!)
|
||||||
// Filtering out enum `RESTEvents` because of interface with similar name `RestEvents`
|
// Filtering out enum `RESTEvents` because of interface with similar name `RestEvents`
|
||||||
// causing next.js export to error
|
// causing next.js export to error
|
||||||
@@ -58,12 +58,12 @@ export const getStaticPaths: GetStaticPaths = async () => {
|
|||||||
if (member.kind === 'Function' && member.overloadIndex && member.overloadIndex > 1) {
|
if (member.kind === 'Function' && member.overloadIndex && member.overloadIndex > 1) {
|
||||||
return {
|
return {
|
||||||
params: {
|
params: {
|
||||||
slug: ['main', 'packages', packageName, `${member.name}:${member.overloadIndex}`],
|
slug: ['packages', packageName, 'main', `${member.name}:${member.overloadIndex}`],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return { params: { slug: ['main', 'packages', packageName, member.name] } };
|
return { params: { slug: ['packages', packageName, 'main', member.name] } };
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
} catch {
|
} catch {
|
||||||
@@ -80,7 +80,7 @@ export const getStaticPaths: GetStaticPaths = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const getStaticProps: GetStaticProps = async ({ params }) => {
|
export const getStaticProps: GetStaticProps = async ({ params }) => {
|
||||||
const [branchName = 'main', , packageName = 'builders', member = 'ActionRowBuilder'] = params!.slug as string[];
|
const [, packageName = 'builders', branchName = 'main', member = 'ActionRowBuilder'] = params!.slug as string[];
|
||||||
|
|
||||||
const [memberName, overloadIndex] = member.split(':') as [string, string | undefined];
|
const [memberName, overloadIndex] = member.split(':') as [string, string | undefined];
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export default function PackagesRoute() {
|
|||||||
<Container pt={96} size="xs">
|
<Container pt={96} size="xs">
|
||||||
<Stack sx={{ flexGrow: 1 }}>
|
<Stack sx={{ flexGrow: 1 }}>
|
||||||
{packages.map((pkg) => (
|
{packages.map((pkg) => (
|
||||||
<Link key={pkg} href={`/docs/main/packages/${pkg}`} passHref>
|
<Link key={pkg} href={`/docs/packages/${pkg}/main`} passHref>
|
||||||
<UnstyledButton className={classes.control} component="a">
|
<UnstyledButton className={classes.control} component="a">
|
||||||
<Group position="apart">
|
<Group position="apart">
|
||||||
<Group>
|
<Group>
|
||||||
@@ -24,7 +24,7 @@ export function findPackage(model: ApiModel, name: string): ApiPackage | undefin
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function generatePath(items: readonly ApiItem[]) {
|
export function generatePath(items: readonly ApiItem[]) {
|
||||||
let path = '/docs/main/packages';
|
let path = '/docs/packages';
|
||||||
for (const item of items) {
|
for (const item of items) {
|
||||||
switch (item.kind) {
|
switch (item.kind) {
|
||||||
case ApiItemKind.Model:
|
case ApiItemKind.Model:
|
||||||
@@ -53,7 +53,7 @@ export function generatePath(items: readonly ApiItem[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return path.replace(/@discordjs\//, '');
|
return path.replace(/@discordjs\/(.*)\/(.*)?/, '$1/main/$2');
|
||||||
}
|
}
|
||||||
|
|
||||||
export function resolveDocComment(item: ApiDocumentedItem) {
|
export function resolveDocComment(item: ApiDocumentedItem) {
|
||||||
|
|||||||
Reference in New Issue
Block a user