404 sayfası eklendi

This commit is contained in:
Yusuf İpek
2021-08-13 16:24:25 +03:00
parent 2f74cdf1f1
commit 87bb65e089
10 changed files with 144 additions and 77 deletions
+27
View File
@@ -0,0 +1,27 @@
import Link from "next/link";
import Head from "next/head";
import { useEffect } from "react";
import { useRouter } from "next/router";
export default function NotFound() {
const router = useRouter();
useEffect(() => {
setTimeout(() => {
router.push("/");
}, 3000);
}, []);
return (
<div className="not-found">
<Head>
<title>404</title>
</Head>
<h1 className="heading-1">404</h1>
<h2 className="heading-2">Aradığınız sayfa bulunamadı!</h2>
<p>
Sizi <Link href="/">anasayfaya</Link> yönlendiriyorum.
</p>
</div>
);
}
+14 -5
View File
@@ -1,7 +1,8 @@
import { createClient } from "contentful";
import Head from "next/head";
import Home from "../commons/home";
export default function App({ posts }) {
export default function App({ rehberler }) {
return (
<div>
<Head>
@@ -12,18 +13,26 @@ export default function App({ posts }) {
/>
<link rel="icon" href="/favicon.ico" />
</Head>
<Home posts={posts} />
<Home rehberler={rehberler} />
</div>
);
}
export async function getStaticProps() {
const res = await fetch("https://jsonplaceholder.typicode.com/posts");
const posts = await res.json();
const client = createClient({
space: process.env.CONTENTFUL_SPACE_ID,
accessToken: process.env.CONTENTFUL_ACCESS_KEY,
});
const res = await client.getEntries({
content_type: "rehber",
order: "-fields.date",
});
return {
props: {
posts,
rehberler: res.items,
},
revalidate: 10,
};
}
+2 -16
View File
@@ -1,5 +1,4 @@
import Head from "next/head";
import Image from "next/image";
import { createClient } from "contentful";
import ReactMarkdown from "react-markdown";
@@ -8,13 +7,13 @@ export default function PostDetails({ posts }) {
return (
<div className="loading">
<Head>
<title> Loading... </title>
<title> Yükleniyor... </title>
</Head>
<h1 className="heading-1 u-center-text">Yükleniyor...</h1>
</div>
);
const { title, featuredImage, rehber, description } = posts.fields;
const { title, rehber, description } = posts.fields;
return (
<div className="markdown">
<Head>
@@ -22,20 +21,7 @@ export default function PostDetails({ posts }) {
<meta name="description" content={description} />
<meta property="og:title" content={`${title} - Teknoloji Rehberleri`} />
<meta property="og:description" content={description} />
<meta
property="og:image"
content={`https:${featuredImage.fields.file.url}`}
/>
</Head>
<Image
src={`https:${featuredImage.fields.file.url}`}
alt={featuredImage.fields.file.fileName}
width={featuredImage.fields.file.details.image.width}
height={featuredImage.fields.file.details.image.height}
className="markdown_featuredImage"
/>
<ReactMarkdown>{rehber}</ReactMarkdown>
</div>
);