+ );
+};
+
+export async function getStaticProps({ locale }) {
+ return {
+ props: {
+ ...(await serverSideTranslations(locale, ["common", "footer"])),
+ // Will be passed to the page component as props
+ },
+ };
+}
+
+export default NotFound;
diff --git a/src/pages/duas/[slug].tsx b/src/pages/duas/[slug].tsx
index becb6b8..7006170 100644
--- a/src/pages/duas/[slug].tsx
+++ b/src/pages/duas/[slug].tsx
@@ -15,6 +15,7 @@ import { useFontSettingsContext } from "@/components/context/font-setting-contex
import { useAudio } from "@/components/context/audio-conext";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import { DefaultSeo } from "next-seo";
+import NotFound from "../404";
// Define the Dua interface
interface Dua {
@@ -64,7 +65,7 @@ const DuaComponent: React.FC = ({
async (nextPage) => {
if (!slug || fetching) return; // Prevent fetching if data is already being fetched
- const id = slug.split("-").pop();
+ const id = slug;
if (!id) return;
setFetching(true); // Set fetching to true when data starts fetching
@@ -82,14 +83,17 @@ const DuaComponent: React.FC = ({
// Append the new results to the existing duaParts
setDuaParts((prev) => [...prev, ...duaResponse.data.results]);
+ console.log(duaResponse);
+ getAudio(id);
+
} catch (error) {
- console.error("Error fetching Dua parts:", error);
+ router.replace("/404")
+ console.log("Error fetching Dua parts:", error);
} finally {
setLoading(false);
setFetching(false); // Reset fetching state after fetching is done
}
- getAudio(id);
},
[slug, fetching, duaParts, getAudio]
); // Dependencies for fetchData
@@ -237,12 +241,13 @@ const DuaComponent: React.FC = ({
},
[fetching]
);
-
+ console.log(duaParts[0]?.seo_field);
+
if (!slug) {
return null; // Handling the case where slug is not available
}
- const title = processSlug(slug); // Title derived from slug
- const description = "This is a detailed description for the specific Dua page."; // You can customize this further
+ const title = duaParts[0]?.seo_field?.title // Title derived from slug
+ const description = duaParts[0]?.seo_field?.description; // You can customize this further
const keywords = "dua, islam, prayer, supplication, dua parts"; // Keywords for SEO
return (