From 28dce9aede9f1bda6484e0472936f0ccd414eacf Mon Sep 17 00:00:00 2001 From: shenlan Date: Mon, 15 Sep 2025 14:47:54 +0800 Subject: [PATCH] fix: add generateStaticParams for dl export (#219) --- ui/dl/README.md | 7 +------ ui/dl/app/[[...slug]]/page.tsx | 17 +++++++++-------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/ui/dl/README.md b/ui/dl/README.md index 7551e6c..988bb8c 100644 --- a/ui/dl/README.md +++ b/ui/dl/README.md @@ -11,15 +11,12 @@ yarn dev Set `NEXT_PUBLIC_DL_BASE_URL` to the object storage endpoint (including the bucket path) before starting the dev server if you want to load data -from a location other than the default `https://dl.svc.plus`. For -example: +from a location other than the default `https://dl.svc.plus`. For example: ```bash NEXT_PUBLIC_DL_BASE_URL=https://storage.example.com/my-bucket yarn dev ``` -from a location other than the default `https://dl.svc.plus`. - ## Build & Deploy @@ -37,5 +34,3 @@ point the exported site at your own storage endpoint and bucket, e.g.: NEXT_PUBLIC_DL_BASE_URL=https://storage.example.com/my-bucket yarn build ``` -point the exported site at your own storage endpoint and bucket. - diff --git a/ui/dl/app/[[...slug]]/page.tsx b/ui/dl/app/[[...slug]]/page.tsx index db56ba8..c8df717 100644 --- a/ui/dl/app/[[...slug]]/page.tsx +++ b/ui/dl/app/[[...slug]]/page.tsx @@ -1,9 +1,3 @@ -export const dynamic = "force-static"; -export const dynamicParams = false; -export async function generateStaticParams() { - return [{ slug: [] }]; -} - import CardGrid from "../../components/CardGrid"; import FileTable from "../../components/FileTable"; import Breadcrumbs from "../../components/Breadcrumbs"; @@ -32,13 +26,20 @@ async function getManifest() { } async function getDir(path: string) { - const res = await fetch(`${BASE_URL}${path}dir.json`, { cache: 'no-store' }); + const res = await fetch(`${BASE_URL}${path}dir.json`, { cache: "no-store" }); if (!res.ok) { - throw new Error('Failed to load dir'); + throw new Error("Failed to load dir"); } return res.json(); } +export function generateStaticParams() { + return [{ slug: [] }]; +} + +export const dynamicParams = false; +export const dynamic = "force-static"; + export default async function Page({ params }: { params: { slug?: string[] } }) { const segs = params.slug ?? []; if (segs.length === 0) {