fix(website): don't crash if no version was found

This commit is contained in:
iCrawl
2025-05-15 22:05:38 +02:00
parent c92a8c27a2
commit 576443c29a
6 changed files with 75 additions and 55 deletions

View File

@@ -2,6 +2,7 @@ import { readFile } from 'node:fs/promises';
import { join } from 'node:path';
import rehypeShikiFromHighlighter from '@shikijs/rehype/core';
import type { Metadata } from 'next';
import { notFound } from 'next/navigation';
import { MDXRemote } from 'next-mdx-remote-client/rsc';
import remarkGfm from 'remark-gfm';
import { DocItem } from '@/components/DocItem';
@@ -89,6 +90,7 @@ export default async function Page({
}
const entryPointString = parsedEntrypoints.join('.');
const node = await fetchNode({
entryPoint: entryPointString,
item: decodeURIComponent(foundItem),
@@ -96,6 +98,10 @@ export default async function Page({
version,
});
if (!node) {
notFound();
}
return (
<main className="mx-auto flex w-full max-w-screen-xl flex-col gap-8 px-6 py-4">
<DocItem node={node} packageName={packageName} version={version} />