diff --git a/next.config.mjs b/next.config.mjs index c50b89d..9c9d64b 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -3,7 +3,6 @@ const nextConfig = { images: { domains: ["avatars.githubusercontent.com"], }, - output: "export", // Add this line for static exports }; export default nextConfig; diff --git a/public/favicons/site.webmanifest b/public/favicons/site.webmanifest deleted file mode 100644 index e4e0b8d..0000000 --- a/public/favicons/site.webmanifest +++ /dev/null @@ -1 +0,0 @@ -{"name":"zobaidulkazi","short_name":"zobaidulkazi","icons":[{"src":"/android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"} \ No newline at end of file diff --git a/public/site.webmanifest b/public/site.webmanifest new file mode 100644 index 0000000..49bd131 --- /dev/null +++ b/public/site.webmanifest @@ -0,0 +1,20 @@ +{ + "name": "Your App Name", + "short_name": "AppName", + "start_url": "/", + "display": "standalone", + "background_color": "#ffffff", + "theme_color": "#000000", + "icons": [ + { + "src": "/icons/icon-192x192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "/icons/icon-512x512.png", + "sizes": "512x512", + "type": "image/png" + } + ] +} diff --git a/src/app/blogs/[bId]/page.tsx b/src/app/blogs/[bId]/page.tsx new file mode 100644 index 0000000..991a57d --- /dev/null +++ b/src/app/blogs/[bId]/page.tsx @@ -0,0 +1,88 @@ +// src/app/blogs/[bId]/page.tsx + +import { notFound } from "next/navigation"; +import { fetchBlogById, fetchBlogs } from "@/lib/blogBid"; + +interface BlogProps { + params: { + bId: string; + }; +} + +interface Blog { + _id: string; + bId: number; + author: { + id: string; + username: string; + fullname: string; + }; + title: string; + subtitle: string; + description: string; + code: string; + image: string; + url: string; + createdAt: string; + updatedAt: string; +} + +export async function generateStaticParams() { + const blogs = await fetchBlogs(); + return blogs.map((blog: Blog) => ({ + bId: blog.bId.toString(), // Use bId as a string + })); +} + +const BlogPage: React.FC = async ({ params }) => { + const bId = parseInt(params.bId, 10); // Convert bId to a number + + const blog = await fetchBlogById(bId); + + if (!blog) { + return notFound(); + } + + return ( +
+

+ {blog.title} +

+

+ {blog.subtitle} +

+ {blog.title} +

+ {blog.description} +

+ + Read more + +
+

+ Code Example +

+
+          {blog.code}
+        
+
+

+ Author: {blog.author.fullname} +

+

+ Created at: {new Date(blog.createdAt).toLocaleDateString()} +

+
+ ); +}; + +export default BlogPage; diff --git a/src/app/blogs/bId.tsx b/src/app/blogs/bId.tsx deleted file mode 100644 index 8268db7..0000000 --- a/src/app/blogs/bId.tsx +++ /dev/null @@ -1,185 +0,0 @@ -"use client"; // Add this line at the top - -import React from "react"; -import { motion } from "framer-motion"; -import create from "zustand"; -import Link from "next/link"; -import NotFoundPage from "@/app/not-found"; -import Loading from "@/components/common/Loading"; - -interface BlogStore { - copied: boolean; - setCopied: (value: boolean) => void; -} - -const useBlogStore = create((set) => ({ - copied: false, - setCopied: (value) => set({ copied: value }), -})); - -interface Author { - id: string; - username: string; - fullname: string; -} - -interface Blog { - _id: string; - bId: number; - author: Author; - title: string; - subtitle: string; - description: string; - code: string; - image: string; - url: string; - createdAt: string; - updatedAt: string; -} - -interface BlogDetailsProps { - params: { - bId: string; - }; -} - -const BlogDetails: React.FC = ({ params }) => { - const { bId } = params; - const { copied, setCopied } = useBlogStore(); - const currentBlogId = parseInt(bId, 10); // Convert blog ID to a number - - const [blog, setBlog] = React.useState(null); - const [loading, setLoading] = React.useState(true); - - const fetchBlogDetails = async (id: number) => { - try { - const response = await fetch( - `https://message-aether.onrender.com/api/blog/${id}` - ); - const data = await response.json(); - if (data.success && data.data) { - setBlog(data.data); - } - } catch (error) { - console.error("Error fetching blog details:", error); - } finally { - setLoading(false); - } - }; - - React.useEffect(() => { - fetchBlogDetails(currentBlogId); - }, [currentBlogId]); - - const copyToClipboard = (code: string) => { - navigator.clipboard.writeText(code); - setCopied(true); - setTimeout(() => { - setCopied(false); - }, 2000); // Reset after 2 seconds - }; - - const nextBlogId = currentBlogId + 1; - const prevBlogId = currentBlogId - 1; - - if (loading) { - return ; - } - - if (!blog) { - return ; - } - - return ( -
- - {blog.title} - - - {blog.subtitle} - - -

- {blog.description} -

- - Read more - - -

- Code Example -

-
-          {blog.code}
-        
- -
-

- Author: {blog.author.fullname} -

-

- Created at: {new Date(blog.createdAt).toLocaleDateString()} -

-
- {prevBlogId > 0 ? ( - - - - ) : ( - - )} - {true ? ( // Assuming there are always subsequent blogs; adjust based on actual data - - - - ) : ( - - )} -
-
- ); -}; - -export default BlogDetails; diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 0ee6865..57bd8a7 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -30,6 +30,7 @@ export default function RootLayout({ sizes="180x180" href={metaDataLinks.faviconLinkAppleTouchIcon} /> +