import Head from "next/head"; import { createClient } from "contentful"; import ReactMarkdown from "react-markdown"; export default function PostDetails({ posts }) { if (!posts) return (
Yükleniyor...

Yükleniyor...

); const { title, rehber, description } = posts.fields; return (
{title} - Teknoloji Rehberleri {rehber}
); } const client = createClient({ space: process.env.CONTENTFUL_SPACE_ID, accessToken: process.env.CONTENTFUL_ACCESS_KEY, }); export const getStaticPaths = async () => { const res = await client.getEntries({ content_type: "rehber" }); const paths = res.items.map((item) => { return { params: { slug: item.fields.slug }, }; }); return { paths, fallback: true, }; }; export async function getStaticProps({ params }) { const { items } = await client.getEntries({ content_type: "rehber", "fields.slug": params.slug, }); if (!items.length) { return { redirect: { destination: "/404", permanent: false } }; } return { props: { posts: items[0] }, revalidate: 10, }; }