Skip to content

Commit 90d1920

Browse files
committed
fix: generate paths
1 parent b0f9b9c commit 90d1920

File tree

1 file changed

+13
-9
lines changed
  • apps/website/src/app/docs/[...slug]

1 file changed

+13
-9
lines changed

apps/website/src/app/docs/[...slug]/page.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export async function generateStaticParams() {
111111
}),
112112
];
113113
} catch {
114-
return { slug: [] };
114+
return { slug: ['packages', '404'] };
115115
}
116116
}),
117117
)
@@ -162,14 +162,18 @@ async function getData(slug: string[]) {
162162
});
163163

164164
let data;
165-
if (process.env.NEXT_PUBLIC_LOCAL_DEV) {
166-
const res = await readFile(join(cwd(), '..', '..', 'packages', packageName, 'docs', 'docs.api.json'), 'utf8');
167-
data = JSON.parse(res);
168-
} else {
169-
const res = await fetch(`https://docs.discordjs.dev/docs/${packageName}/${branchName}.api.json`, {
170-
next: { revalidate: 3_600 },
171-
});
172-
data = await res.json();
165+
try {
166+
if (process.env.NEXT_PUBLIC_LOCAL_DEV) {
167+
const res = await readFile(join(cwd(), '..', '..', 'packages', packageName, 'docs', 'docs.api.json'), 'utf8');
168+
data = JSON.parse(res);
169+
} else {
170+
const res = await fetch(`https://docs.discordjs.dev/docs/${packageName}/${branchName}.api.json`, {
171+
next: { revalidate: 3_600 },
172+
});
173+
data = await res.json();
174+
}
175+
} catch {
176+
notFound();
173177
}
174178

175179
const model = createApiModel(data);

0 commit comments

Comments
 (0)