From 754ee0e50982995dce60adb9bbc191ff7ed4d68c Mon Sep 17 00:00:00 2001 From: SandeepYadav99 <134907060+SandeepYadav99@users.noreply.github.com> Date: Sun, 20 Aug 2023 15:49:58 +0530 Subject: [PATCH] [fix] Bug --- next.config.js | 2 - src/app/category/[categoryIds]/page.js | 57 ++++++++++++++++++---- src/pages/Category/Category.js | 3 +- src/pages/Category/Category_Post.js | 8 +-- src/pages/CategoryDetail/CategoryDetail.js | 47 ------------------ 5 files changed, 52 insertions(+), 65 deletions(-) delete mode 100644 src/pages/CategoryDetail/CategoryDetail.js diff --git a/next.config.js b/next.config.js index f491e4c..10c7ec3 100644 --- a/next.config.js +++ b/next.config.js @@ -1,7 +1,5 @@ /** @type {import('next').NextConfig} */ const nextConfig = { - basePath: '/TRAVEL-TIPPLER', - trailingSlash: true, images: { domains: ["www.traveltippler.com"], unoptimized: true, diff --git a/src/app/category/[categoryIds]/page.js b/src/app/category/[categoryIds]/page.js index a274abf..d41bb7f 100644 --- a/src/app/category/[categoryIds]/page.js +++ b/src/app/category/[categoryIds]/page.js @@ -1,17 +1,54 @@ -import React from "react"; -import CategoryDetail from "@/pages/CategoryDetail/CategoryDetail"; +"use client"; +import React from 'react' +import Follow from "@/pages/Category/Social_Links"; +import RecentPost from "@/pages/Category/RecentPost"; +import CategorysList from "@/pages/Category/CategorysList"; +import { useParams } from 'next/navigation'; +import CATEGORYs from '@/components/helper/CATEGORYs'; +import Category_Post from '@/pages/Category/Category_Post'; +import useCategoryName from '@/components/hooks/ConvertCaps'; +import formatCategory from '@/components/hooks/ConvertSmall'; -const CategoryIds = () => { - // const postData = await fetchPostLists(); - - return ( - - ); -}; -export default CategoryIds; +const CategoryDetail = () => { + const params = useParams(); + const name = formatCategory(params.categoryIds); + return ( +
+
+
+

{name}

+
+
+ {CATEGORYs.map((category, index) => { + // eslint-disable-next-line react-hooks/rules-of-hooks + const capsFormat = useCategoryName(category.category) + if (capsFormat === params.categoryIds) { + return ( + + ); + } + return null; + })} +
+
+ + + +
+
+ ) +} +export default CategoryDetail // export const fetchPostLists = async () => { // const data = await fetch("https://www.traveltippler.com/wp-json/wp/v2/posts"); // const responseData = await data.json(); diff --git a/src/pages/Category/Category.js b/src/pages/Category/Category.js index 823aaae..8f63c7f 100644 --- a/src/pages/Category/Category.js +++ b/src/pages/Category/Category.js @@ -6,9 +6,8 @@ import RecentPost from "./RecentPost"; import CategorysList from "./CategorysList"; import Category_Post from "./Category_Post"; - const Category = ({fetch_categories}) => { -console.log(fetch_categories) + return (
diff --git a/src/pages/Category/Category_Post.js b/src/pages/Category/Category_Post.js index cb8ce1d..84016c4 100644 --- a/src/pages/Category/Category_Post.js +++ b/src/pages/Category/Category_Post.js @@ -6,8 +6,8 @@ import getFirstTwoLines from "@/components/hooks/ConvertWordLength"; import useCategoryName from "@/components/hooks/ConvertCaps"; import { useRouter } from "next/navigation"; -const Category_Post = ({ id, image,category, aurther,heading , date, description}) => { - +const Category_Post = ({ id, image, category, aurther, heading, date, description }) => { + const router = useRouter(); const categoryType = useCategoryName(category); @@ -21,10 +21,10 @@ const Category_Post = ({ id, image,category, aurther,heading , date, descriptio const headingHandler = (id) => { router.push(`/category/${categoryType}/${id}`); }; - + return (
- +
{ - const params = useParams(); - - return ( -
-
-
-

{params.categoryIds}

-
-
- {CATEGORYs.map((category, index) => { - if (category.category.toLowerCase().split(" ").join("-") === params.categoryIds) { - return ( - - ); - } - return null; - })} - {/* // const urlParts = category.link.split("/"); */} -
-
- - - -
-
- ) -} - -export default CategoryDetail \ No newline at end of file