diff --git a/package-lock.json b/package-lock.json
index 1bf6edb..959e83b 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -5221,9 +5221,9 @@
}
},
"node_modules/caniuse-lite": {
- "version": "1.0.30001566",
- "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001566.tgz",
- "integrity": "sha512-ggIhCsTxmITBAMmK8yZjEhCO5/47jKXPu6Dha/wuCS4JePVL+3uiDEBuhu2aIoT+bqTOR8L76Ip1ARL9xYsEJA==",
+ "version": "1.0.30001571",
+ "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001571.tgz",
+ "integrity": "sha512-tYq/6MoXhdezDLFZuCO/TKboTzuQ/xR5cFdgXPfDtM7/kchBO3b4VWghE/OAi/DV7tTdhmLjZiZBZi1fA/GheQ==",
"funding": [
{
"type": "opencollective",
diff --git a/pages/404.tsx b/pages/404.tsx
index 28e6fd9..0563100 100644
--- a/pages/404.tsx
+++ b/pages/404.tsx
@@ -1,6 +1,6 @@
import Head from "next/head";
import Image from "next/image";
-import Layout from "../src/components/Layout";
+import Layout from "../src/components/Layout/Layout";
import { links } from "../src/utils/links";
const Custom404 = () => {
diff --git a/pages/500.tsx b/pages/500.tsx
index e4a219d..2445356 100644
--- a/pages/500.tsx
+++ b/pages/500.tsx
@@ -1,5 +1,5 @@
import Head from "next/head";
-import Layout from "../src/components/Layout";
+import Layout from "../src/components/Layout/Layout";
import { links } from "../src/utils/links";
const Custom500 = () => {
diff --git a/pages/_error.tsx b/pages/_error.tsx
index e88eea5..9972ba3 100644
--- a/pages/_error.tsx
+++ b/pages/_error.tsx
@@ -1,6 +1,6 @@
import Head from "next/head";
import PropTypes from "prop-types";
-import Layout from "../src/components/Layout";
+import Layout from "../src/components/Layout/Layout";
import { links } from "../src/utils/links";
const Error = ({ statusCode }) => {
diff --git a/pages/about.tsx b/pages/about.tsx
index 234d389..7b26166 100644
--- a/pages/about.tsx
+++ b/pages/about.tsx
@@ -1,5 +1,5 @@
import Head from "next/head";
-import Layout from "../src/components/Layout";
+import Layout from "../src/components/Layout/Layout";
import { getAllCards } from "../src/utils/contentfulPosts";
import { links } from "../src/utils/links";
@@ -34,20 +34,26 @@ const About = ({ cards }) => {
};
export async function getStaticProps() {
- const res = await getAllCards("card");
- const cards = res;
+ try {
+ const res = await getAllCards("card");
+ const cards = res;
- if (!cards) {
+ if (!cards) {
+ return {
+ notFound: true,
+ };
+ }
+
+ return {
+ props: {
+ cards,
+ },
+ };
+ } catch (error) {
return {
notFound: true,
};
}
-
- return {
- props: {
- cards,
- },
- };
}
export default About;
diff --git a/pages/blog/[slug].tsx b/pages/blog/[slug].tsx
index ab900e9..6c4b568 100644
--- a/pages/blog/[slug].tsx
+++ b/pages/blog/[slug].tsx
@@ -1,6 +1,6 @@
import Head from "next/head";
import Image from "next/image";
-import Layout from "../../src/components/Layout";
+import Layout from "../../src/components/Layout/Layout";
import { getAllPosts, getPostBySlug } from "../../src/utils/contentfulPosts";
import { links } from "../../src/utils/links";
diff --git a/pages/index.tsx b/pages/index.tsx
index f088382..d22b68e 100644
--- a/pages/index.tsx
+++ b/pages/index.tsx
@@ -1,6 +1,6 @@
import Head from "next/head";
-import Layout from "../src/components/Layout";
-import PostList from "../src/components/PostList";
+import Layout from "../src/components/Layout/Layout";
+import PostList from "../src/components/PostList/PostList";
import { links } from "../src/utils/links";
import { getAllPosts } from "../src/utils/contentfulPosts";
@@ -36,20 +36,26 @@ const HomePage = ({ posts }) => {
export default HomePage;
export async function getStaticProps() {
- const res = await getAllPosts("posts");
- const posts = res.map((p) => {
- return p.fields;
- });
+ try {
+ const res = await getAllPosts("posts");
+ const posts = res.map((p) => {
+ return p.fields;
+ });
- if (!posts) {
+ if (!posts) {
+ return {
+ notFound: true,
+ };
+ }
+
+ return {
+ props: {
+ posts,
+ },
+ };
+ } catch (error) {
return {
notFound: true,
};
}
-
- return {
- props: {
- posts,
- },
- };
}
diff --git a/src/__tests__/Footer.test.tsx b/src/components/Footer/Footer.test.tsx
similarity index 90%
rename from src/__tests__/Footer.test.tsx
rename to src/components/Footer/Footer.test.tsx
index c33b17d..8a2816e 100644
--- a/src/__tests__/Footer.test.tsx
+++ b/src/components/Footer/Footer.test.tsx
@@ -1,7 +1,7 @@
import { render, waitFor } from "@testing-library/react";
import "@testing-library/jest-dom";
-import Footer from "../components/Footer";
+import Footer from "./Footer";
describe("Footer Component", () => {
test("should have the copyright in the footer", async () => {
diff --git a/src/components/Footer.tsx b/src/components/Footer/Footer.tsx
similarity index 100%
rename from src/components/Footer.tsx
rename to src/components/Footer/Footer.tsx
diff --git a/src/__tests__/Header.test.tsx b/src/components/Header/Header.test.tsx
similarity index 94%
rename from src/__tests__/Header.test.tsx
rename to src/components/Header/Header.test.tsx
index 212d57e..bbbe00c 100644
--- a/src/__tests__/Header.test.tsx
+++ b/src/components/Header/Header.test.tsx
@@ -1,6 +1,6 @@
import { render, cleanup, waitFor } from "@testing-library/react";
import "@testing-library/jest-dom";
-import Header from "../components/Header";
+import Header from "./Header";
describe("Header", () => {
afterEach(cleanup);
diff --git a/src/components/Header.tsx b/src/components/Header/Header.tsx
similarity index 95%
rename from src/components/Header.tsx
rename to src/components/Header/Header.tsx
index 31e2aca..6acd4ba 100644
--- a/src/components/Header.tsx
+++ b/src/components/Header/Header.tsx
@@ -1,4 +1,3 @@
-/* eslint-disable react/no-unknown-property */
import Link from "next/link";
type Props = {
diff --git a/src/__tests__/Layout.test.tsx b/src/components/Layout/Layout.test.tsx
similarity index 80%
rename from src/__tests__/Layout.test.tsx
rename to src/components/Layout/Layout.test.tsx
index 91327fe..23693ef 100644
--- a/src/__tests__/Layout.test.tsx
+++ b/src/components/Layout/Layout.test.tsx
@@ -7,7 +7,7 @@ import {
} from "@testing-library/react";
import "@testing-library/jest-dom";
-import Layout from "../components/Layout";
+import Layout from "./Layout";
describe("Layout", () => {
const links = [
@@ -22,6 +22,11 @@ describe("Layout", () => {
id: 1,
},
];
+
+ it("renders without crashing", () => {
+ render(