Skip to content

Commit 52b1e15

Browse files
authored
Return 404 when Hadith data is empty or missing (#3201)
* fix: handle empty hadiths data in getStaticProps Added a check in getStaticProps to return a notFound response if the hadiths data is empty, ensuring proper handling of cases where no hadiths are available for the requested chapter. * refactor: simplify empty hadiths check in getStaticProps
1 parent cfa46db commit 52b1e15

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/pages/[chapterId]/hadith.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ export const getStaticProps: GetStaticProps = async ({ params, locale }) => {
119119
getPagesLookup({ chapterNumber: Number(chapterNumber), mushaf: mushafId }),
120120
]);
121121

122+
if (!hadithsData?.hadiths?.length) return { notFound: true };
123+
122124
const versesResponse = buildVersesResponse(chaptersData, pagesLookupResponse);
123125

124126
return {

0 commit comments

Comments
 (0)