From 044cdb4280075db05ac996dec64bda6558724f8f Mon Sep 17 00:00:00 2001
From: parsa aghaei
Date: Mon, 30 Sep 2024 14:37:43 +0330
Subject: [PATCH] aboutMe data is serverside now
---
src/app/_components/about-me/page.tsx | 26 ++++++++++++-------------
src/app/page.tsx | 28 +--------------------------
2 files changed, 13 insertions(+), 41 deletions(-)
diff --git a/src/app/_components/about-me/page.tsx b/src/app/_components/about-me/page.tsx
index cae083d..d7c6fd6 100644
--- a/src/app/_components/about-me/page.tsx
+++ b/src/app/_components/about-me/page.tsx
@@ -1,6 +1,4 @@
-"use client";
-
-import React, { useEffect, useState } from "react";
+import React from "react";
import Skeleton from "react-loading-skeleton";
import "react-loading-skeleton/dist/skeleton.css";
@@ -26,11 +24,11 @@ type AboutMeDataType = {
skills: SkillType[];
};
-type AboutMeProps = {
- data: AboutMeDataType;
-};
-
-export default function AboutMe({ data }: AboutMeProps) {
+export default async function AboutMe() {
+ const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/about-me`, {
+ cache: "no-store", // غیرفعال کردن کش
+ });
+ const aboutMeData: AboutMeDataType = await response.json();
return (
- {data?.title || }
+ {aboutMeData?.title || }
- {data?.description || }
+ {aboutMeData?.description || }
- {data?.skills ? (
- data?.skills.map((skill, key) => (
+ {aboutMeData?.skills ? (
+ aboutMeData?.skills.map((skill, key) => (
-
{skill.title}
@@ -66,9 +64,9 @@ export default function AboutMe({ data }: AboutMeProps) {
)}
- {data?.image ? (
+ {aboutMeData?.image ? (
-

+
) : (
diff --git a/src/app/page.tsx b/src/app/page.tsx
index ddf1d17..25a079f 100644
--- a/src/app/page.tsx
+++ b/src/app/page.tsx
@@ -5,33 +5,7 @@ import AboutMe from "./_components/about-me/page";
import Services from "./_components/services/page";
import MyProjects from "./_components/my-projects/page";
-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 (
@@ -108,7 +82,7 @@ export default async function Home() {
-
+