diff --git a/app/blog/blogdetail/Blog.jsx b/app/blog/blogdetail/Blog.jsx new file mode 100644 index 0000000..6c19afe --- /dev/null +++ b/app/blog/blogdetail/Blog.jsx @@ -0,0 +1,64 @@ +import singlePost from "../../assets/images/single-post/1.jpg"; +import { BlogLoader, ImageLoader } from "../../lib/SkeletonLoaders"; +// import Image from "next/image"; +// import LazyImage from "../../lib/LazyImage"; + +/** + * Renders a blog post component. + * @returns {JSX.Element} The rendered blog post component. + */ +function Blog({ blogItem, imgUrl, loader }) { + // Generate a unique ID + const uniqueId = `element_${Math.random().toString(36).substr(2, 9)}`; + + const blogImg = `${imgUrl}/${blogItem?.meta_value || singlePost}`; + + const imgLoaderStyles = { + "--loader-width": "750px", + "--loader-height": "550px", + }; + + const headerLoaderStyles = { + "--text-container-width": "300px", + "--text-container-height": "18px", + }; + + const bodyTextLoaderStyles = { + "--text-container-width": "770px", + "--text-container-height": "15px", + }; + + return ( + <> +
+
+ {loader ? ( +
+ +
+ ) : ( + {blogItem?.meta_value + )} +
+ {loader ? ( +
+ +
+ ) : ( +

{blogItem?.post_title}

+ )} + {loader ? ( +
+ +
+ ) : ( +
+ )} +
+ + ); +} + +export default Blog; diff --git a/app/blog/blogdetail/BlogSideBar.js b/app/blog/blogdetail/BlogSideBar.js new file mode 100644 index 0000000..520a049 --- /dev/null +++ b/app/blog/blogdetail/BlogSideBar.js @@ -0,0 +1,69 @@ +import React from "react"; +import Link from "next/link"; +import BlogImg1 from "../../assets/images/blog/p1.jpg"; + +/** + * Renders a sidebar for a blog. + * @param {Object} blogs - An object containing the data for the blog posts. + * @returns {JSX.Element} - JSX code that renders the blog sidebar. + */ +function BlogSideBar({ blogs }) { + /** + * Renders other blog posts. + * This is an Array of JSX elements representing the other blog posts. + */ + const renderOtherBlogPosts = () => { + return blogs?.blogdata?.slice(0, 4).map((post) => { + const blogDate = new Date(post.post_date).toLocaleDateString("en-US", { + year: "numeric", + month: "short", + day: "numeric", + }); + + const blogImg = + post.meta_value != null + ? `${blogs?.image_url}/${post.meta_value}` + : BlogImg1; + + return ( +
+ + blog-img + +
+ {post?.post_title} +
+ {blogDate} +
+ ); + }); + }; + + return ( +
+ + +
+ ); +} + +export default BlogSideBar; diff --git a/app/blog/blogdetail/[id]/page.js b/app/blog/blogdetail/[id]/page.js new file mode 100644 index 0000000..a42cf9d --- /dev/null +++ b/app/blog/blogdetail/[id]/page.js @@ -0,0 +1,84 @@ +"use client" +import React, { useEffect, useMemo, useState } from 'react' +import { useParams } from 'next/navigation'; +import ServiceNav from '@/app/components/navigation/ServiceNav'; +import HeroNews from '@/app/components/News/HeroNews'; +import FooterHomeOne from '../../../components/FooterHomeOne'; +import BackToTop from '@/app/components/BackToTop'; +import BlogData from '@/app/Services/BlogData'; + +import Blog from '../Blog' +import BlogSideBar from '../BlogSideBar' + +// must be a better way to centralize the style = TEMPORARY USE +import '../../../assets/css/bootstrap.min.css'; +import '../../../assets/css/custom-animated.css'; +import '../../../assets/css/default.css'; +import '../../../assets/css/font-awesome.min.css'; +import '../../../assets/css/magnific-popup.css'; +import '../../../assets/css/main.css'; +import '../../../assets/css/style.css'; + + +function page() { + const [isLoading, setIsLoading] = useState(false); + const [blogs, setBlogs] = useState([]); + const { id } = useParams(); + + useEffect(() => { + const fetchBlogs = async () => { + setIsLoading(true); + try { + const res = await BlogData(); + setBlogs(res.data); + setIsLoading(false) + } catch (err) { + console.log("Error loading blogdata", err); + setIsLoading(false) + } + }; + + fetchBlogs(); + }, []); + + const blogItem = useMemo(() => { + return blogs?.blogdata?.find((item) => item.id == id); + }, [blogs, id]); + return ( + <> + + + {/* Renders the hero section */} + + + {/* Renders the blog content and sidebar */} +
+
+
+
+ +
+
+ +
+
+
+
+ + + + + ) +} + +export default page \ No newline at end of file diff --git a/app/blog/blogdetail/[id]/page.tsx b/app/blog/blogdetail/[id]/page.tsx deleted file mode 100644 index 3038944..0000000 --- a/app/blog/blogdetail/[id]/page.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import React from 'react' -import FooterHomeOne from '../../../components/FooterHomeOne'; - -// must be a better way to centralize the style = TEMPORARY USE -import '../../../assets/css/bootstrap.min.css'; -import '../../../assets/css/custom-animated.css'; -import '../../../assets/css/default.css'; -import '../../../assets/css/font-awesome.min.css'; -import '../../../assets/css/magnific-popup.css'; -import '../../../assets/css/main.css'; -import '../../../assets/css/style.css'; - - -function page() { - return ( - <> -
Bog Detail Here
- - - - ) -} - -export default page \ No newline at end of file diff --git a/app/blog/blogdetail/page.tsx b/app/blog/blogdetail/page.tsx deleted file mode 100644 index 543d84c..0000000 --- a/app/blog/blogdetail/page.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import React from 'react' -import FooterHomeOne from '../../components/FooterHomeOne'; - -// must be a better way to centralize the style = TEMPORARY USE -import '../../assets/css/bootstrap.min.css'; -import '../../assets/css/custom-animated.css'; -import '../../assets/css/default.css'; -import '../../assets/css/font-awesome.min.css'; -import '../../assets/css/magnific-popup.css'; -import '../../assets/css/main.css'; -import '../../assets/css/style.css'; - - -function page() { - return ( - <> -
Bog Detail Here
- - - - ) -} - -export default page \ No newline at end of file diff --git a/app/components/FooterHomeOne.js b/app/components/FooterHomeOne.js index c759fec..a6f1ab8 100644 --- a/app/components/FooterHomeOne.js +++ b/app/components/FooterHomeOne.js @@ -118,7 +118,7 @@ function FooterHomeOne({ className }) {
-
+
  • diff --git a/app/components/News/Blogs.js b/app/components/News/Blogs.js index ce1ff24..f2b7dda 100644 --- a/app/components/News/Blogs.js +++ b/app/components/News/Blogs.js @@ -3,6 +3,7 @@ import React, { useEffect, useState } from "react"; import Link from "next/link"; import blogOne from "../../assets/images/blog/1.jpg"; import BlogData from "../../Services/BlogData"; +// import Image from "next/image"; /** * Fetches blog data from an API and renders the blogs on the page. diff --git a/app/lib/LazyImage.js b/app/lib/LazyImage.js index 0d3770c..6df62bd 100644 --- a/app/lib/LazyImage.js +++ b/app/lib/LazyImage.js @@ -1,3 +1,4 @@ +"use client" import React, { useEffect, useRef, useState } from 'react'; /** diff --git a/public/assets/images/single-post/1.jpg b/public/assets/images/single-post/1.jpg new file mode 100644 index 0000000..c2a5e4f Binary files /dev/null and b/public/assets/images/single-post/1.jpg differ