From 6d3c546b726eb18c00ee6915dd5546d408124f73 Mon Sep 17 00:00:00 2001
From: Ayush <99096397+ayush4345@users.noreply.github.com>
Date: Wed, 28 Feb 2024 00:43:39 +0530
Subject: [PATCH] added custom script
---
package.json | 4 ++--
src/app/blogs/[blogid]/page.js | 3 ++-
src/app/events/[eventid]/page.js | 3 ++-
src/app/projects/[projectid]/page.jsx | 5 +++--
src/components/Navbar/Navbar.js | 9 ---------
src/components/api.js | 14 ++++++++------
src/components/blog/blogDetail.jsx | 5 +++--
src/components/blog/blogList.jsx | 4 ++--
src/components/event/eventDetail.jsx | 5 +++--
src/components/event/eventList.jsx | 5 +++--
src/components/project/projectDetail.jsx | 7 ++++---
11 files changed, 32 insertions(+), 32 deletions(-)
diff --git a/package.json b/package.json
index 719a958..f0f4efd 100644
--- a/package.json
+++ b/package.json
@@ -7,8 +7,8 @@
"build": "next build",
"start": "next start",
"lint": "next lint",
- "static": "node script.js && next build && next export",
- "custom-script": "node script.js"
+ "custom-script": "node script.js",
+ "static": "node script.js && next build && next export && touch ./out/.nojekyll && echo 'mbsaiaditya.github.io' > ./out/CNAME"
},
"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 fd4e3d1..a572b14 100644
--- a/src/app/blogs/[blogid]/page.js
+++ b/src/app/blogs/[blogid]/page.js
@@ -1,4 +1,5 @@
import BlogId from "@/components/blog/blogDetail";
+import jsonData from '../../../../public/blog-response.json'
export default function BlogDetail({ params }){
return(
@@ -7,7 +8,7 @@ export default function BlogDetail({ params }){
}
export async function generateStaticParams() {
- const posts = await fetch('/blog-response.json').then((res) => res.json())
+ const posts = jsonData
return posts.items.map((post) => ({
blogid: post.blog_slug,
diff --git a/src/app/events/[eventid]/page.js b/src/app/events/[eventid]/page.js
index b142176..5bacaa4 100644
--- a/src/app/events/[eventid]/page.js
+++ b/src/app/events/[eventid]/page.js
@@ -1,4 +1,5 @@
import EventId from "@/components/event/eventDetail";
+import jsonData from '../../../../public/event-response.json'
export default function EventDetail({ params }){
return(
@@ -7,7 +8,7 @@ export default function EventDetail({ params }){
}
export async function generateStaticParams() {
- const posts = await fetch('/event-response.json').then((res) => res.json())
+ const posts = jsonData
return posts.items.map((post) => ({
eventid: post.event_slug,
diff --git a/src/app/projects/[projectid]/page.jsx b/src/app/projects/[projectid]/page.jsx
index 932413d..8fc58b0 100644
--- a/src/app/projects/[projectid]/page.jsx
+++ b/src/app/projects/[projectid]/page.jsx
@@ -1,4 +1,5 @@
import ProjectId from "@/components/project/projectDetail";
+import jsonData from '../../../../public/project-response.json'
export default function ProjectDetail({ params }){
return(
@@ -7,8 +8,8 @@ export default function ProjectDetail({ params }){
}
export async function generateStaticParams() {
- const posts = await fetch('/project-response.json').then((res) => res.json())
-
+ const posts = jsonData
+
return posts.items.map((post) => ({
projectid: post.project_slug,
}))
diff --git a/src/components/Navbar/Navbar.js b/src/components/Navbar/Navbar.js
index c6c9cad..97353cf 100644
--- a/src/components/Navbar/Navbar.js
+++ b/src/components/Navbar/Navbar.js
@@ -62,15 +62,6 @@ const Navbar = () => {
Projects
-
-
- Location
-
-
diff --git a/src/components/api.js b/src/components/api.js
index 85b2aa3..2baeebf 100644
--- a/src/components/api.js
+++ b/src/components/api.js
@@ -1,13 +1,15 @@
+import jsonData from '../../public/project-response.json'
+
export const fetchProjects = async () => {
try {
- const response = await fetch('/project-response.json');
- console.log(response);
+ // const response = await fetch('/project-response.json');
+ // console.log(response);
- if (!response.ok) {
- throw new Error(`API request failed with status: ${response.status}`);
- }
+ // if (!response.ok) {
+ // throw new Error(`API request failed with status: ${response.status}`);
+ // }
- const data = await response.json();
+ const data = jsonData;
return data.items || [];
} catch (error) {
console.error('Error fetching data from API:', error);
diff --git a/src/components/blog/blogDetail.jsx b/src/components/blog/blogDetail.jsx
index b7d0945..4d46732 100644
--- a/src/components/blog/blogDetail.jsx
+++ b/src/components/blog/blogDetail.jsx
@@ -6,6 +6,7 @@ import gfm from 'remark-gfm'
import './styleblog.css'
// Import Tailwind CSS classes
import 'tailwindcss/tailwind.css';
+import jsonData from '../../../public/blog-response.json'
// Component definition
const BlogId = ({ params }) => {
@@ -18,8 +19,8 @@ const BlogId = ({ params }) => {
const fetchData = async () => {
try {
// Fetch data from the API
- const response = await fetch('/blog-response.json');
- const data = await response.json();
+ // const response = await fetch('/blog-response.json');
+ const data = await jsonData;
console.log("check", data);
// Find the blog post with the matching id
const matchingBlog = data.items.find(blog => blog?.blog_slug === params.blogid);
diff --git a/src/components/blog/blogList.jsx b/src/components/blog/blogList.jsx
index be0fb9f..4174efb 100644
--- a/src/components/blog/blogList.jsx
+++ b/src/components/blog/blogList.jsx
@@ -1,6 +1,7 @@
"use client"
import React, { useEffect, useState } from 'react';
import BlogCard from './Blogcard';
+import jsonData from '../../../public/blog-response.json';
const BlogList = () => {
const [blogs, setBlogs] = useState([]);
@@ -10,8 +11,7 @@ const BlogList = () => {
useEffect(() => {
const fetchData = async () => {
try {
- const response = await fetch('/blog-response.json');
- const data = await response.json();
+ const data = await jsonData;
setBlogs(data.items);
} catch (error) {
console.error('Error fetching data:', error);
diff --git a/src/components/event/eventDetail.jsx b/src/components/event/eventDetail.jsx
index 783e577..c48e0f4 100644
--- a/src/components/event/eventDetail.jsx
+++ b/src/components/event/eventDetail.jsx
@@ -6,6 +6,7 @@ import ReactMarkdown from "react-markdown";
import './styleblog.css'
// Import Tailwind CSS classes
import 'tailwindcss/tailwind.css';
+import jsonData from '../../../public/event-response.json'
// Component definition
const EventId = ({ params }) => {
@@ -18,8 +19,8 @@ const EventId = ({ params }) => {
const fetchData = async () => {
try {
// Fetch data from the API
- const response = await fetch('/event-response.json');
- const data = await response.json();
+ // const response = await fetch('/event-response.json');
+ const data = await jsonData;
// 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
diff --git a/src/components/event/eventList.jsx b/src/components/event/eventList.jsx
index ba3ae15..821a83e 100644
--- a/src/components/event/eventList.jsx
+++ b/src/components/event/eventList.jsx
@@ -1,6 +1,7 @@
"use client"
import React, { useEffect, useState } from 'react';
import BlogCard from './eventCard';
+import jsonData from '../../../public/event-response.json'
const EventList = () => {
const [blogs, setBlogs] = useState([]);
@@ -10,8 +11,8 @@ const EventList = () => {
useEffect(() => {
const fetchData = async () => {
try {
- const response = await fetch('/event-response.json');
- const data = await response.json();
+ // const response = await fetch('/event-response.json');
+ const data = await jsonData;
setBlogs(data.items);
} catch (error) {
console.error('Error fetching data:', error);
diff --git a/src/components/project/projectDetail.jsx b/src/components/project/projectDetail.jsx
index 5cc288a..11808da 100644
--- a/src/components/project/projectDetail.jsx
+++ b/src/components/project/projectDetail.jsx
@@ -6,6 +6,7 @@ import ReactMarkdown from "react-markdown";
import './styleblog.css'
// Import Tailwind CSS classes
import 'tailwindcss/tailwind.css';
+import jsonData from '../../../public/project-response.json'
// Component definition
const ProjectId = ({ params }) => {
@@ -18,8 +19,8 @@ const ProjectId = ({ params }) => {
const fetchData = async () => {
try {
// Fetch data from the API
- const response = await fetch('/project-response.json');
- const data = await response.json();
+ // const response = await fetch('/project-response.json');
+ const data = await jsonData;
console.log("check", data);
// Find the blog post with the matching id
const matchingBlog = data.items.find(project => project?.project_slug === params.projectid);
@@ -62,7 +63,7 @@ const ProjectId = ({ params }) => {
{projectData.project_description}
- {projectData.project_authors}
+ {projectData.project_authors}