fix: add generateStaticParams for dl export (#219)

This commit is contained in:
shenlan 2025-09-15 14:47:54 +08:00 committed by GitHub
parent 5be2f5d5fb
commit 28dce9aede
2 changed files with 10 additions and 14 deletions

View File

@ -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.

View File

@ -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) {