2025-07-14 23:07:09 +00:00
|
|
|
import { Suspense } from "react";
|
|
|
|
|
import { getBrowseParamsFromPathParam } from "../hooks/utils";
|
2025-06-06 19:38:16 +00:00
|
|
|
import { CodePreviewPanel } from "./components/codePreviewPanel";
|
2025-07-14 23:07:09 +00:00
|
|
|
import { Loader2 } from "lucide-react";
|
2025-06-06 19:38:16 +00:00
|
|
|
import { TreePreviewPanel } from "./components/treePreviewPanel";
|
2025-10-13 11:40:15 +00:00
|
|
|
import { Metadata } from "next";
|
2025-10-13 15:52:47 +00:00
|
|
|
import { parsePathForTitle} from "@/lib/utils";
|
2025-10-13 11:40:15 +00:00
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
params: {
|
|
|
|
|
domain: string;
|
|
|
|
|
path: string[];
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
2025-10-13 15:52:47 +00:00
|
|
|
let title = 'Browse'; // Default Fallback
|
2025-10-13 11:40:15 +00:00
|
|
|
|
|
|
|
|
try {
|
2025-10-13 15:52:47 +00:00
|
|
|
title = parsePathForTitle(params.path);
|
2025-10-13 11:40:15 +00:00
|
|
|
|
|
|
|
|
} catch (error) {
|
2025-10-13 15:52:47 +00:00
|
|
|
// TODO: Maybe I need to look into a better way of handling this error.
|
|
|
|
|
// for now, it is just a log, fallback tab title and prevents the app from crashing.
|
2025-10-13 11:40:15 +00:00
|
|
|
console.error("Failed to generate metadata title from path:", params.path, error);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
2025-10-13 15:52:47 +00:00
|
|
|
title,
|
2025-10-13 11:40:15 +00:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-14 23:07:09 +00:00
|
|
|
interface BrowsePageProps {
|
2025-08-22 18:48:29 +00:00
|
|
|
params: Promise<{
|
2025-07-14 23:07:09 +00:00
|
|
|
path: string[];
|
2025-08-22 18:48:29 +00:00
|
|
|
}>;
|
2025-07-14 23:07:09 +00:00
|
|
|
}
|
|
|
|
|
|
2025-08-22 18:48:29 +00:00
|
|
|
export default async function BrowsePage(props: BrowsePageProps) {
|
|
|
|
|
const params = await props.params;
|
|
|
|
|
|
|
|
|
|
const {
|
|
|
|
|
path: _rawPath,
|
|
|
|
|
} = params;
|
|
|
|
|
|
2025-09-01 15:45:05 +00:00
|
|
|
const rawPath = _rawPath.join('/');
|
2025-10-13 15:52:47 +00:00
|
|
|
console.log("rawPath:", rawPath);
|
2025-07-14 23:07:09 +00:00
|
|
|
const { repoName, revisionName, path, pathType } = getBrowseParamsFromPathParam(rawPath);
|
|
|
|
|
|
2025-01-07 18:27:42 +00:00
|
|
|
return (
|
2025-06-06 19:38:16 +00:00
|
|
|
<div className="flex flex-col h-full">
|
2025-07-14 23:07:09 +00:00
|
|
|
<Suspense fallback={
|
|
|
|
|
<div className="flex flex-col w-full min-h-full items-center justify-center">
|
|
|
|
|
<Loader2 className="w-4 h-4 animate-spin" />
|
|
|
|
|
Loading...
|
|
|
|
|
</div>
|
|
|
|
|
}>
|
|
|
|
|
{pathType === 'blob' ? (
|
|
|
|
|
<CodePreviewPanel
|
|
|
|
|
path={path}
|
|
|
|
|
repoName={repoName}
|
|
|
|
|
revisionName={revisionName}
|
|
|
|
|
/>
|
|
|
|
|
) : (
|
|
|
|
|
<TreePreviewPanel
|
|
|
|
|
path={path}
|
|
|
|
|
repoName={repoName}
|
|
|
|
|
revisionName={revisionName}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</Suspense>
|
2025-06-06 19:38:16 +00:00
|
|
|
</div>
|
2025-01-07 18:27:42 +00:00
|
|
|
)
|
2025-05-28 23:08:42 +00:00
|
|
|
}
|
2025-06-06 19:38:16 +00:00
|
|
|
|