Skip to content

Commit

Permalink
added custom script
Browse files Browse the repository at this point in the history
  • Loading branch information
ayush4345 committed Feb 27, 2024
1 parent 0ae9088 commit 6d3c546
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 32 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion src/app/blogs/[blogid]/page.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import BlogId from "@/components/blog/blogDetail";
import jsonData from '../../../../public/blog-response.json'

export default function BlogDetail({ params }){
return(
Expand All @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion src/app/events/[eventid]/page.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import EventId from "@/components/event/eventDetail";
import jsonData from '../../../../public/event-response.json'

export default function EventDetail({ params }){
return(
Expand All @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions src/app/projects/[projectid]/page.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import ProjectId from "@/components/project/projectDetail";
import jsonData from '../../../../public/project-response.json'

export default function ProjectDetail({ params }){
return(
Expand All @@ -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,
}))
Expand Down
9 changes: 0 additions & 9 deletions src/components/Navbar/Navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,6 @@ const Navbar = () => {
Projects
</Link>
</li>
<li className={styles.nav__item}>
<Link
href="/location"
className={styles.nav__link}
onClick={closeMobileMenu}
>
Location
</Link>
</li>
</ul>
<div className={styles.nav__close} id="nav-close" onClick={toggleMenu}>
<IoClose />
Expand Down
14 changes: 8 additions & 6 deletions src/components/api.js
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
5 changes: 3 additions & 2 deletions src/components/blog/blogDetail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/components/blog/blogList.jsx
Original file line number Diff line number Diff line change
@@ -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([]);
Expand All @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions src/components/event/eventDetail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/components/event/eventList.jsx
Original file line number Diff line number Diff line change
@@ -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([]);
Expand All @@ -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);
Expand Down
7 changes: 4 additions & 3 deletions src/components/project/projectDetail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand All @@ -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);
Expand Down Expand Up @@ -62,7 +63,7 @@ const ProjectId = ({ params }) => {
{projectData.project_description}
</div>
<div className="text-xl text-purple-200/90 font-medium font-sans mt-6 flex justify-between items-center">
<span>{projectData.project_authors}</span>
<span>{projectData.project_authors}</span>
</div>
</div>
</section>
Expand Down

0 comments on commit 6d3c546

Please sign in to comment.