Skip to content

Commit 28b5f0e

Browse files
committed
fallbackを追加してみる
1 parent e35517b commit 28b5f0e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/app/news/[slug]/page.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ interface Props {
1212
searchParams: {};
1313
}
1414

15-
export async function generateStaticParams() {
15+
// newsの中身が無かった場合の処理
16+
export async function getStaticPaths() {
1617
const docsDirectory = path.join(process.cwd(), `docs`, `news`);
1718
const docs = await fs.readdir(docsDirectory);
18-
return docs.map((doc) => ({ slug: doc.replace(/\.md$/, '') }));
19+
const paths = docs.map((doc) => ({ params: { slug: doc.replace(/\.md$/, '') } }));
20+
return { paths, fallback: false };
1921
}
2022

2123
export async function generateMetadata({ params }: Props): Promise<Metadata> {

0 commit comments

Comments
 (0)