diff --git a/package.json b/package.json index ce96d8e..136e9ba 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "dev": "next dev", "build": "next build", "start": "next start", - "lint": "next lint" + "lint": "next lint", + "static": "next build && next export" }, "dependencies": { "@fortawesome/fontawesome-svg-core": "^6.5.1", diff --git a/src/app/blogs/[blogid]/page.js b/src/app/blogs/[blogid]/page.js index d211c6c..988fb4c 100644 --- a/src/app/blogs/[blogid]/page.js +++ b/src/app/blogs/[blogid]/page.js @@ -1,91 +1,15 @@ -// Import necessary modules -"use client" -import { useEffect, useState } from "react"; -import Navbar from "@/components/Navbar/Navbar"; -import Footer from "@/components/footer"; -import ReactMarkdown from "react-markdown"; -import './styleblog.css' -// Import Tailwind CSS classes -import 'tailwindcss/tailwind.css'; - -// Component definition -const BlogId = ({ params }) => { - console.log(params.blogid) - // State to store the fetched data - const [blogData, setBlogData] = useState(null); - - // Effect to fetch data when the component mounts - useEffect(() => { - const fetchData = async () => { - try { - // Fetch data from the API - const response = await fetch('https://tetragram.codered.cloud/api/v2/pages/?type=blog.BlogPage&fields=*'); - const data = await response.json(); - console.log("check", data); - // Find the blog post with the matching id - const matchingBlog = data.items.find(blog => blog?.blog_slug === params.blogid); - console.log("matchingBlog", data.items[0]); - // Update the state with the matching blog data - setBlogData(matchingBlog); - console.log("blog :", matchingBlog.blog_img_url) - - } catch (error) { - console.error('Error fetching data:', error); - } - }; - - // Call the fetchData function - fetchData(); - }, [params.blogid]); // Include params.id in the dependency array to refetch data when id changes - console.log(blogData?.blog_tags.split(",")) - - let inputDate = blogData?.published_on; - let dateObj = new Date(inputDate); - let day = dateObj.getDate(); - let month = dateObj.toLocaleString('default', { month: 'short' }); - let year = dateObj.getFullYear(); - - let formattedDate = `${day} ${month} ${year}`; - - // Render the component - return ( - <> - -
-
- {blogData ? ( -
-
-
-
- {blogData?.blog_tags.split(",").map((data, index) => { - return ( - {data} - ) - } - )} -
-
- {blogData.title} -
-
- {blogData.blog_description} -
-
- {blogData.blog_authors}{formattedDate} -
-
-
- {blogData.blog_body} -
- ) : ( -

Loading...

- )} -
-
- - ); -}; - -// Export the component -export default BlogId; +import BlogId from "@/components/blog/blogDetail"; + +export default function BlogDetail({ params }){ + return( + + ) +} + +export async function generateStaticParams() { + const posts = await fetch('https://tetragram.codered.cloud/api/v2/pages/?type=blog.BlogPage&fields=*').then((res) => res.json()) + + return posts.items.map((post) => ({ + blogid: post.blog_slug, + })) +} diff --git a/src/app/blogs/page.js b/src/app/blogs/page.js index d38a366..2049019 100644 --- a/src/app/blogs/page.js +++ b/src/app/blogs/page.js @@ -1,64 +1,7 @@ -"use client" -import React, { useEffect, useState } from 'react'; -import BlogCard from './Blogcard'; - -const BlogList = () => { - const [blogs, setBlogs] = useState([]); - const [currentPage, setCurrentPage] = useState(1); - const blogsPerPage = 6; - - useEffect(() => { - const fetchData = async () => { - try { - const response = await fetch('https://tetragram.codered.cloud/api/v2/pages/?type=blog.BlogPage&fields=*'); - const data = await response.json(); - setBlogs(data.items); - } catch (error) { - console.error('Error fetching data:', error); - } - }; - - fetchData(); - }, []); - - // Calculate the index range for the current page - const indexOfLastBlog = currentPage * blogsPerPage; - const indexOfFirstBlog = indexOfLastBlog - blogsPerPage; - const currentBlogs = blogs.slice(indexOfFirstBlog, indexOfLastBlog); - - // Function to handle page change - const handlePageChange = (newPage) => { - setCurrentPage(newPage); - }; +import BlogList from "@/components/blog/blogList"; +export default function Blog() { return ( - <> -
-
-
- Blog -
-
-
- {blogs.map((blog, index) => { - return ( - <> - - - ) - })} -
-
- - ); -}; - -export default BlogList; + + ) +} \ No newline at end of file diff --git a/src/app/events/[eventid]/page.js b/src/app/events/[eventid]/page.js index f8671d3..eb2e87d 100644 --- a/src/app/events/[eventid]/page.js +++ b/src/app/events/[eventid]/page.js @@ -1,88 +1,15 @@ -// Import necessary modules -"use client" -import { useEffect, useState } from "react"; -import Navbar from "@/components/Navbar/Navbar"; -import Footer from "@/components/footer"; -import ReactMarkdown from "react-markdown"; -import './styleblog.css' -// Import Tailwind CSS classes -import 'tailwindcss/tailwind.css'; - -// Component definition -const BlogId = ({ params }) => { - console.log(params.blogid) - // State to store the fetched data - const [eventData, setEventData] = useState(null); - - // Effect to fetch data when the component mounts - useEffect(() => { - const fetchData = async () => { - try { - // Fetch data from the API - const response = await fetch('https://tetragram.codered.cloud/api/v2/pages/?type=events.EventsPage&fields=*'); - const data = await response.json(); - // Find the blog post with the matching id - const matchingBlog = data.items.find(blog => blog?.event_slug === params.eventid); - // Update the state with the matching blog data - setEventData(matchingBlog); - - } catch (error) { - console.error('Error fetching data:', error); - } - }; - - // Call the fetchData function - fetchData(); - }, [params.blogid]); // Include params.id in the dependency array to refetch data when id changes - console.log(eventData?.event_tags.split(",")) - - let inputDate = eventData?.event_date; - let dateObj = new Date(inputDate); - let day = dateObj.getDate(); - let month = dateObj.toLocaleString('default', { month: 'short' }); - let year = dateObj.getFullYear(); - - let formattedDate = `${day} ${month} ${year}`; - - // Render the component - return ( - <> - -
-
- {eventData ? ( -
-
-
-
- {eventData?.event_tags.split(",").map((data, index) => { - return ( - {data} - ) - } - )} -
-
- {eventData.title} -
-
- -
-
- {eventData.event_organizer}{formattedDate} -
-
-
- {eventData.event_body} -
- ) : ( -

Loading...

- )} -
-
- - ); -}; - -// Export the component -export default BlogId; +import EventId from "@/components/event/eventDetail"; + +export default function EventDetail({ params }){ + return( + + ) +} + +export async function generateStaticParams() { + const posts = await fetch('https://tetragram.codered.cloud/api/v2/pages/?type=events.EventsPage&fields=*').then((res) => res.json()) + + return posts.items.map((post) => ({ + eventid: post.event_slug, + })) +} \ No newline at end of file diff --git a/src/app/events/page.js b/src/app/events/page.js index d2d79de..c7713c9 100644 --- a/src/app/events/page.js +++ b/src/app/events/page.js @@ -1,65 +1,7 @@ -"use client" -import React, { useEffect, useState } from 'react'; -import BlogCard from './eventCard'; - -const EventList = () => { - const [blogs, setBlogs] = useState([]); - const [currentPage, setCurrentPage] = useState(1); - const blogsPerPage = 6; - - useEffect(() => { - const fetchData = async () => { - try { - const response = await fetch('https://tetragram.codered.cloud/api/v2/pages/?type=events.EventsPage&fields=*'); - const data = await response.json(); - setBlogs(data.items); - } catch (error) { - console.error('Error fetching data:', error); - } - }; - - fetchData(); - }, []); - - // Calculate the index range for the current page - const indexOfLastBlog = currentPage * blogsPerPage; - const indexOfFirstBlog = indexOfLastBlog - blogsPerPage; - const currentBlogs = blogs.slice(indexOfFirstBlog, indexOfLastBlog); - - // Function to handle page change - const handlePageChange = (newPage) => { - setCurrentPage(newPage); - }; +import EventList from "@/components/event/eventList"; +export default function Event(){ return ( - <> -
-
-
- Events -
-
-
- {blogs.map((blog, index) => { - return ( - <> - - - ) - })} -
-
- - ); -}; - -export default EventList; + + ) +} \ No newline at end of file diff --git a/src/app/projects/[projectid]/page.jsx b/src/app/projects/[projectid]/page.jsx index 25aeeb7..828efd4 100644 --- a/src/app/projects/[projectid]/page.jsx +++ b/src/app/projects/[projectid]/page.jsx @@ -1,82 +1,15 @@ -// Import necessary modules -"use client" -import { useEffect, useState } from "react"; -import Navbar from "@/components/Navbar/Navbar"; -import Footer from "@/components/footer"; -import ReactMarkdown from "react-markdown"; -import './styleblog.css' -// Import Tailwind CSS classes -import 'tailwindcss/tailwind.css'; - -// Component definition -const ProjectId = ({ params }) => { - console.log(params.blogid) - // State to store the fetched data - const [projectData, setProjectData] = useState(null); - - // Effect to fetch data when the component mounts - useEffect(() => { - const fetchData = async () => { - try { - // Fetch data from the API - const response = await fetch('https://tetragram.codered.cloud/api/v2/pages/?type=projects.ProjectsPage&fields=*'); - const data = await response.json(); - console.log("check", data); - // Find the blog post with the matching id - const matchingBlog = data.items.find(project => project?.project_slug === params.projectid); - console.log("matchingBlog", data.items[0]); - // Update the state with the matching blog data - setProjectData(matchingBlog); - console.log("blog :", matchingBlog.project_img_url) - - } catch (error) { - console.error('Error fetching data:', error); - } - }; - - // Call the fetchData function - fetchData(); - }, [params.blogid]); // Include params.id in the dependency array to refetch data when id changes - console.log(projectData?.project_tags.split(",")) - - return ( - <> - -
-
- {projectData ? ( -
-
-
-
- {projectData?.project_tags.split(",").map((data, index) => { - return ( - {data} - ) - } - )} -
-
- {projectData.title} -
-
- {projectData.project_description} -
-
- {projectData.project_authors} -
-
-
- {projectData.project_body} -
- ) : ( -

Loading...

- )} -
-
- - ); -}; - -// Export the component -export default ProjectId; +import ProjectId from "@/components/project/projectDetail"; + +export default function ProjectDetail({ params }){ + return( + + ) +} + +export async function generateStaticParams() { + const posts = await fetch('https://tetragram.codered.cloud/api/v2/pages/?type=projects.ProjectsPage&fields=*').then((res) => res.json()) + + return posts.items.map((post) => ({ + projectid: post.project_slug, + })) +} \ No newline at end of file diff --git a/src/app/projects/page.js b/src/app/projects/page.js index af3c822..97b9202 100644 --- a/src/app/projects/page.js +++ b/src/app/projects/page.js @@ -1,24 +1,7 @@ -// Page.js -"use client"; -import { useEffect, useState } from 'react'; -import ProjectsPage from "@/components/ProjectsPage"; -import { fetchProjects } from '@/components/api'; - -export default function Page() { - const [projects, setProjects] = useState([]); - - useEffect(() => { - const fetchData = async () => { - const projectsData = await fetchProjects(); - setProjects(projectsData); - }; - - fetchData(); - }, []); +import ProjectList from "@/components/project/projectList"; +export default function Project() { return ( -
- -
- ); -} + + ) +} \ No newline at end of file diff --git a/src/app/blogs/Blogcard.js b/src/components/blog/Blogcard.js similarity index 100% rename from src/app/blogs/Blogcard.js rename to src/components/blog/Blogcard.js diff --git a/src/app/blogs/Blogcard.module.css b/src/components/blog/Blogcard.module.css similarity index 100% rename from src/app/blogs/Blogcard.module.css rename to src/components/blog/Blogcard.module.css diff --git a/src/app/blogs/Bloglist.css b/src/components/blog/Bloglist.css similarity index 100% rename from src/app/blogs/Bloglist.css rename to src/components/blog/Bloglist.css diff --git a/src/app/blogs/blog.png b/src/components/blog/blog.png similarity index 100% rename from src/app/blogs/blog.png rename to src/components/blog/blog.png diff --git a/src/components/blog/blogDetail.jsx b/src/components/blog/blogDetail.jsx new file mode 100644 index 0000000..e9ce226 --- /dev/null +++ b/src/components/blog/blogDetail.jsx @@ -0,0 +1,91 @@ +"use client" + +import { useEffect, useState } from "react"; +import Navbar from "@/components/Navbar/Navbar"; +import Footer from "@/components/footer"; +import ReactMarkdown from "react-markdown"; +import './styleblog.css' +// Import Tailwind CSS classes +import 'tailwindcss/tailwind.css'; + +// Component definition +const BlogId = ({ params }) => { + console.log(params.blogid) + // State to store the fetched data + const [blogData, setBlogData] = useState(null); + + // Effect to fetch data when the component mounts + useEffect(() => { + const fetchData = async () => { + try { + // Fetch data from the API + const response = await fetch('https://tetragram.codered.cloud/api/v2/pages/?type=blog.BlogPage&fields=*'); + const data = await response.json(); + console.log("check", data); + // Find the blog post with the matching id + const matchingBlog = data.items.find(blog => blog?.blog_slug === params.blogid); + console.log("matchingBlog", data.items[0]); + // Update the state with the matching blog data + setBlogData(matchingBlog); + console.log("blog :", matchingBlog.blog_img_url) + + } catch (error) { + console.error('Error fetching data:', error); + } + }; + + // Call the fetchData function + fetchData(); + }, [params.blogid]); // Include params.id in the dependency array to refetch data when id changes + console.log(blogData?.blog_tags.split(",")) + + let inputDate = blogData?.published_on; + let dateObj = new Date(inputDate); + let day = dateObj.getDate(); + let month = dateObj.toLocaleString('default', { month: 'short' }); + let year = dateObj.getFullYear(); + + let formattedDate = `${day} ${month} ${year}`; + + // Render the component + return ( + <> + +
+
+ {blogData ? ( +
+
+
+
+ {blogData?.blog_tags.split(",").map((data, index) => { + return ( + {data} + ) + } + )} +
+
+ {blogData.title} +
+
+ {blogData.blog_description} +
+
+ {blogData.blog_authors}{formattedDate} +
+
+
+ {blogData.blog_body} +
+ ) : ( +

Loading...

+ )} +
+
+ + ); +}; + +// Export the component +export default BlogId; diff --git a/src/components/blog/blogList.jsx b/src/components/blog/blogList.jsx new file mode 100644 index 0000000..d38a366 --- /dev/null +++ b/src/components/blog/blogList.jsx @@ -0,0 +1,64 @@ +"use client" +import React, { useEffect, useState } from 'react'; +import BlogCard from './Blogcard'; + +const BlogList = () => { + const [blogs, setBlogs] = useState([]); + const [currentPage, setCurrentPage] = useState(1); + const blogsPerPage = 6; + + useEffect(() => { + const fetchData = async () => { + try { + const response = await fetch('https://tetragram.codered.cloud/api/v2/pages/?type=blog.BlogPage&fields=*'); + const data = await response.json(); + setBlogs(data.items); + } catch (error) { + console.error('Error fetching data:', error); + } + }; + + fetchData(); + }, []); + + // Calculate the index range for the current page + const indexOfLastBlog = currentPage * blogsPerPage; + const indexOfFirstBlog = indexOfLastBlog - blogsPerPage; + const currentBlogs = blogs.slice(indexOfFirstBlog, indexOfLastBlog); + + // Function to handle page change + const handlePageChange = (newPage) => { + setCurrentPage(newPage); + }; + + return ( + <> +
+
+
+ Blog +
+
+
+ {blogs.map((blog, index) => { + return ( + <> + + + ) + })} +
+
+ + ); +}; + +export default BlogList; diff --git a/src/app/blogs/[blogid]/styleblog.css b/src/components/blog/styleblog.css similarity index 100% rename from src/app/blogs/[blogid]/styleblog.css rename to src/components/blog/styleblog.css diff --git a/src/app/events/Eventcard.module.css b/src/components/event/Eventcard.module.css similarity index 100% rename from src/app/events/Eventcard.module.css rename to src/components/event/Eventcard.module.css diff --git a/src/app/events/Eventlist.css b/src/components/event/Eventlist.css similarity index 100% rename from src/app/events/Eventlist.css rename to src/components/event/Eventlist.css diff --git a/src/app/events/blog.png b/src/components/event/blog.png similarity index 100% rename from src/app/events/blog.png rename to src/components/event/blog.png diff --git a/src/app/events/eventCard.js b/src/components/event/eventCard.js similarity index 100% rename from src/app/events/eventCard.js rename to src/components/event/eventCard.js diff --git a/src/components/event/eventDetail.jsx b/src/components/event/eventDetail.jsx new file mode 100644 index 0000000..a057850 --- /dev/null +++ b/src/components/event/eventDetail.jsx @@ -0,0 +1,88 @@ +// Import necessary modules +"use client" +import { useEffect, useState } from "react"; +import Navbar from "@/components/Navbar/Navbar"; +import Footer from "@/components/footer"; +import ReactMarkdown from "react-markdown"; +import './styleblog.css' +// Import Tailwind CSS classes +import 'tailwindcss/tailwind.css'; + +// Component definition +const EventId = ({ params }) => { + console.log(params.blogid) + // State to store the fetched data + const [eventData, setEventData] = useState(null); + + // Effect to fetch data when the component mounts + useEffect(() => { + const fetchData = async () => { + try { + // Fetch data from the API + const response = await fetch('https://tetragram.codered.cloud/api/v2/pages/?type=events.EventsPage&fields=*'); + const data = await response.json(); + // Find the blog post with the matching id + const matchingBlog = data.items.find(blog => blog?.event_slug === params.eventid); + // Update the state with the matching blog data + setEventData(matchingBlog); + + } catch (error) { + console.error('Error fetching data:', error); + } + }; + + // Call the fetchData function + fetchData(); + }, [params.blogid]); // Include params.id in the dependency array to refetch data when id changes + console.log(eventData?.event_tags.split(",")) + + let inputDate = eventData?.event_date; + let dateObj = new Date(inputDate); + let day = dateObj.getDate(); + let month = dateObj.toLocaleString('default', { month: 'short' }); + let year = dateObj.getFullYear(); + + let formattedDate = `${day} ${month} ${year}`; + + // Render the component + return ( + <> + +
+
+ {eventData ? ( +
+
+
+
+ {eventData?.event_tags.split(",").map((data, index) => { + return ( + {data} + ) + } + )} +
+
+ {eventData.title} +
+
+ +
+
+ {eventData.event_organizer}{formattedDate} +
+
+
+ {eventData.event_body} +
+ ) : ( +

Loading...

+ )} +
+
+ + ); +}; + +// Export the component +export default EventId; diff --git a/src/components/event/eventList.jsx b/src/components/event/eventList.jsx new file mode 100644 index 0000000..d2d79de --- /dev/null +++ b/src/components/event/eventList.jsx @@ -0,0 +1,65 @@ +"use client" +import React, { useEffect, useState } from 'react'; +import BlogCard from './eventCard'; + +const EventList = () => { + const [blogs, setBlogs] = useState([]); + const [currentPage, setCurrentPage] = useState(1); + const blogsPerPage = 6; + + useEffect(() => { + const fetchData = async () => { + try { + const response = await fetch('https://tetragram.codered.cloud/api/v2/pages/?type=events.EventsPage&fields=*'); + const data = await response.json(); + setBlogs(data.items); + } catch (error) { + console.error('Error fetching data:', error); + } + }; + + fetchData(); + }, []); + + // Calculate the index range for the current page + const indexOfLastBlog = currentPage * blogsPerPage; + const indexOfFirstBlog = indexOfLastBlog - blogsPerPage; + const currentBlogs = blogs.slice(indexOfFirstBlog, indexOfLastBlog); + + // Function to handle page change + const handlePageChange = (newPage) => { + setCurrentPage(newPage); + }; + + return ( + <> +
+
+
+ Events +
+
+
+ {blogs.map((blog, index) => { + return ( + <> + + + ) + })} +
+
+ + ); +}; + +export default EventList; diff --git a/src/app/events/[eventid]/styleblog.css b/src/components/event/styleblog.css similarity index 100% rename from src/app/events/[eventid]/styleblog.css rename to src/components/event/styleblog.css diff --git a/src/components/project/projectDetail.jsx b/src/components/project/projectDetail.jsx new file mode 100644 index 0000000..25aeeb7 --- /dev/null +++ b/src/components/project/projectDetail.jsx @@ -0,0 +1,82 @@ +// Import necessary modules +"use client" +import { useEffect, useState } from "react"; +import Navbar from "@/components/Navbar/Navbar"; +import Footer from "@/components/footer"; +import ReactMarkdown from "react-markdown"; +import './styleblog.css' +// Import Tailwind CSS classes +import 'tailwindcss/tailwind.css'; + +// Component definition +const ProjectId = ({ params }) => { + console.log(params.blogid) + // State to store the fetched data + const [projectData, setProjectData] = useState(null); + + // Effect to fetch data when the component mounts + useEffect(() => { + const fetchData = async () => { + try { + // Fetch data from the API + const response = await fetch('https://tetragram.codered.cloud/api/v2/pages/?type=projects.ProjectsPage&fields=*'); + const data = await response.json(); + console.log("check", data); + // Find the blog post with the matching id + const matchingBlog = data.items.find(project => project?.project_slug === params.projectid); + console.log("matchingBlog", data.items[0]); + // Update the state with the matching blog data + setProjectData(matchingBlog); + console.log("blog :", matchingBlog.project_img_url) + + } catch (error) { + console.error('Error fetching data:', error); + } + }; + + // Call the fetchData function + fetchData(); + }, [params.blogid]); // Include params.id in the dependency array to refetch data when id changes + console.log(projectData?.project_tags.split(",")) + + return ( + <> + +
+
+ {projectData ? ( +
+
+
+
+ {projectData?.project_tags.split(",").map((data, index) => { + return ( + {data} + ) + } + )} +
+
+ {projectData.title} +
+
+ {projectData.project_description} +
+
+ {projectData.project_authors} +
+
+
+ {projectData.project_body} +
+ ) : ( +

Loading...

+ )} +
+
+ + ); +}; + +// Export the component +export default ProjectId; diff --git a/src/components/project/projectList.jsx b/src/components/project/projectList.jsx new file mode 100644 index 0000000..1f5afd9 --- /dev/null +++ b/src/components/project/projectList.jsx @@ -0,0 +1,24 @@ +// Page.js +"use client"; +import { useEffect, useState } from 'react'; +import ProjectsPage from "@/components/ProjectsPage"; +import { fetchProjects } from '@/components/api'; + +export default function ProjectList() { + const [projects, setProjects] = useState([]); + + useEffect(() => { + const fetchData = async () => { + const projectsData = await fetchProjects(); + setProjects(projectsData); + }; + + fetchData(); + }, []); + + return ( +
+ +
+ ); +} diff --git a/src/app/projects/[projectid]/styleblog.css b/src/components/project/styleblog.css similarity index 100% rename from src/app/projects/[projectid]/styleblog.css rename to src/components/project/styleblog.css