Skip to content

Commit

Permalink
Feat(Lib): Change Fetch Strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
Ikram-Maulana committed Apr 24, 2023
1 parent 5707e4b commit c4f7662
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 33 deletions.
29 changes: 14 additions & 15 deletions src/app/(portfolio)/page.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
import ButtonAccent from "@/components/button-accent";
import ProjectCard from "@/components/project-card";
import SectionHeader from "@/components/section-header";
import SocialList from "@/components/social-list";
import TechList from "@/components/tech-list";
import { socialConfig } from "@/config/socials";
import { techConfig } from "@/config/tech";
import { MainProjectItem } from "@/types";
import prisma from "@/lib/prisma";
import { ArrowRight } from "lucide-react";
import dynamic from "next/dynamic";
import Image from "next/image";
import { Tokens } from "../../../mirrorful/.mirrorful/theme";
import ButtonAccent from "@/components/button-accent";
import { ArrowRight } from "lucide-react";

const ContactSection = dynamic(() => import("@/components/contact-section"), {
ssr: false,
});

const getFeaturedProjects = async (): Promise<MainProjectItem> => {
let baseUrl = "http://localhost:3000";
if (process.env.VERCEL_URL) {
baseUrl = process.env.VERCEL_URL;
const getFeaturedProjects = async () => {
try {
const projects = await prisma.projects.findMany({
where: {
featured: true,
},
});

return projects;
} catch (error) {
return [];
}
console.log(baseUrl);
const res = await fetch(`${baseUrl}/projects/api`, {
next: {
revalidate: 60,
},
});
const data = await res.json();
return (data as { data: MainProjectItem }).data;
};

export default async function Home() {
Expand Down
17 changes: 0 additions & 17 deletions src/app/(portfolio)/projects/api/route.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export type ProjectItem = {
name: string;
description: string;
image_url: string;
techs: {
techs?: {
name: string;
}[];
github_url: string;
Expand Down

0 comments on commit c4f7662

Please sign in to comment.