import { notFound } from 'next/navigation';
import { getPageData } from "@/utils/data";
import { getLocalPageData } from "@/data/presentation";
import Presentation from "@/components/presentation/Presentation";

export default async function PresentationPage({ params }) {
  const resolvedParams = await params;
  const slugArr = resolvedParams.slug;

  // 优先从本地markdown文件获取数据
  const localData = await getLocalPageData(slugArr);
  
  if (localData.data) {
    // 如果本地文件存在，直接使用本地数据
    return <Presentation data={localData.data} />;
  }

  // 如果本地文件不存在，从API获取数据
  const { data, error } = await getPageData({
    slug_list: slugArr,
    downloadFiles: true
  });

  if (error || !data) {
    notFound();
  }

  return <Presentation data={data} />;
}
