diff --git a/package.json b/package.json index 7ec872a..ac0dc10 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "0.1.0", "private": true, "scripts": { - "dev": "next dev", + "dev": "next dev --turbo", "build": "next build", "start": "next start", "lint": "next lint", diff --git a/src/app/_components/about-me/page.tsx b/src/app/_components/about-me/page.tsx index 2eb32c8..cae083d 100644 --- a/src/app/_components/about-me/page.tsx +++ b/src/app/_components/about-me/page.tsx @@ -4,7 +4,7 @@ import React, { useEffect, useState } from "react"; import Skeleton from "react-loading-skeleton"; import "react-loading-skeleton/dist/skeleton.css"; -type Skill = { +type SkillType = { id: 1; title: string; image: string; @@ -16,46 +16,36 @@ type Skill = { updated_at: string; }; -type AboutMeData = { +type AboutMeDataType = { id: number; title: string; description: string; image: string; created_at: string; updated_at: string; - skills: Skill[]; + skills: SkillType[]; }; -export default function AboutMe() { - const [aboutMe, setAboutMe] = useState(null); - useEffect(() => { - const fetchAboutMeData = async () => { - const res = await fetch("/api/about-me"); - if (res.ok) { - const data = await res.json(); - setAboutMe(data); - } else { - console.error("Failed to fetch about me data"); - } - }; - fetchAboutMeData(); - }, []); +type AboutMeProps = { + data: AboutMeDataType; +}; +export default function AboutMe({ data }: AboutMeProps) { return (
-
+

- {aboutMe?.title || } + {data?.title || }

- {aboutMe?.description || } + {data?.description || }

    - {aboutMe?.skills ? ( - aboutMe?.skills.map((skill, key) => ( + {data?.skills ? ( + data?.skills.map((skill, key) => (
  • {skill.title}

    @@ -76,9 +66,9 @@ export default function AboutMe() { )}
- {aboutMe?.image ? ( + {data?.image ? (
- profile picture + profile picture
) : ( diff --git a/src/app/api/about-me/route.ts b/src/app/api/about-me/route.ts index 79e1ce9..be55cd2 100644 --- a/src/app/api/about-me/route.ts +++ b/src/app/api/about-me/route.ts @@ -4,6 +4,6 @@ export async function GET() { const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/about-me`, { cache: "no-store" // غیرفعال کردن کش }); - const data = await response.json(); + const data = await response.json(); return NextResponse.json(data); } diff --git a/src/app/not-found.tsx b/src/app/not-found.tsx index 995ef08..ff835f9 100644 --- a/src/app/not-found.tsx +++ b/src/app/not-found.tsx @@ -3,8 +3,6 @@ import Link from "next/link"; export default function NotFound() { const imageUrl = `/images/404/${Math.floor(Math.random() * 5) + 1}.jpg`; - console.log(imageUrl); - return (
404 illustration diff --git a/src/app/page.tsx b/src/app/page.tsx index 3c5df12..ddf1d17 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -5,12 +5,39 @@ import AboutMe from "./_components/about-me/page"; import Services from "./_components/services/page"; import MyProjects from "./_components/my-projects/page"; -export default function Home() { +type SkillType = { + id: 1; + title: string; + image: string; + description: string; + link: string; + percentage: number; + about_me_id: number; + created_at: string; + updated_at: string; +}; + +type AboutMeDataType = { + id: number; + title: string; + description: string; + image: string; + created_at: string; + updated_at: string; + skills: SkillType[]; +}; + +export default async function Home() { + const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/about-me`, { + cache: "no-store", // غیرفعال کردن کش + }); + let aboutMeData: AboutMeDataType = await response.json(); + return (
{/* Home */}
{/* start */} @@ -81,7 +108,7 @@ export default function Home() {
- + @@ -93,4 +120,3 @@ export default function Home() {
); } -