44 lines
1.2 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { notFound } from 'next/navigation';
import { getPageData } from "@/utils/data";
import { getLocalPageData } from "@/data/presentation";
import Presentation from "@/components/presentation/Presentation";
const baseSlug = 'presentation';
const LoadingSpinner = () => (
<div className="flex justify-center items-center p-8">
<div className="animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500"></div>
</div>
);
export default async function Page({ params, searchParams }) {
const resolvedParams = await params;
const slug = resolvedParams.slug || [];
const slugArr = [baseSlug, ...(Array.isArray(slug) ? slug : [slug])];
const { data, error } = await getPageData({
slug_list: slugArr,
downloadFiles: true,
});
if (error) {
notFound();
}
if (data) {
// 优先从本地markdown文件获取数据
const localData = await getLocalPageData(slugArr);
if (localData.data) {
// 如果本地文件存在,直接使用本地数据
return <Presentation data={localData.data} />;
}
// 如果本地文件不存在使用API数据
return <Presentation data={data} />;
} else {
notFound();
}
}