Skip to content

Commit

Permalink
get settings from cms
Browse files Browse the repository at this point in the history
  • Loading branch information
nvti committed Oct 31, 2024
1 parent 7d4880f commit 5957f9b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 28 deletions.
36 changes: 36 additions & 0 deletions src/app/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,39 @@ export async function getPost(slug: string) {
}
)(slug);
}

export async function getSettings() {
return unstable_cache(
async () => {
const res = await fetch("https://cms.tihado.com/api/settings", {
headers: {
Authorization: `Bearer ${process.env.TAP_API_KEY}`,
},
next: {
revalidate: 300, // 5 minutes
},
});

if (!res.ok) {
throw new Error("Failed to fetch data from CMS");
}

const data = (await res.json()) as {
settings: {
socials: {
label: string;
url: string;
icon: string;
}[];
};
};

return data.settings;
},
["settings"],
{
revalidate: 300, // 5 minutes
tags: ["settings"],
}
)();
}
31 changes: 3 additions & 28 deletions src/components/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,10 @@
import { getSettings } from "@/app/action";
import Image from "next/image";
import Link from "next/link";

const socials = [
{
label: "Google Scholar",
url: "https://scholar.google.com/citations?user=OGb4sloAAAAJ&hl=fr",
icon: "https://upload.wikimedia.org/wikipedia/commons/c/c7/Google_Scholar_logo.svg",
},
{
label: "Github",
url: "https://github.com/honghanhh",
icon: "https://upload.wikimedia.org/wikipedia/commons/9/91/Octicons-mark-github.svg",
},
{
label: "LinkedIn",
url: "https://www.linkedin.com/in/thi-hong-hanh-tran-0b886212a/",
icon: "https://upload.wikimedia.org/wikipedia/commons/f/f8/LinkedIn_icon_circle.svg",
},
{
label: "Website",
url: "https://hanh.zootopi.dev/",
icon: "https://zootopi.dev/img/logo.svg",
},
{
label: "Mail",
url: "mailto:[email protected]",
icon: "https://cdncms.tihado.com/media/m2vzf0hh-image.png",
},
];
export const Footer = async () => {
const { socials } = await getSettings();

export const Footer = () => {
return (
<footer className="flex h-24 sm:gap-3 max-sm:flex-col">
<div className="flex flex-1 sm:justify-end items-center justify-center">
Expand Down

0 comments on commit 5957f9b

Please sign in to comment.