From 02404e76685069f50ec1ef73f0cf0d3bf3bf27af Mon Sep 17 00:00:00 2001 From: Viet Hung Nguyen Date: Sat, 25 Nov 2023 23:24:00 -0800 Subject: [PATCH 1/3] Modify config file --- next.config.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/next.config.js b/next.config.js index a083fc6..f703ff7 100644 --- a/next.config.js +++ b/next.config.js @@ -4,7 +4,12 @@ const nextConfig = { swcMinify: true, output: "export", images: { - domains: ["cdn.sanity.io"], + remotePatterns: [ + { + hostname: "cdn.sanity.io", + }, + ], + unoptimized: true, }, webpack: (config, { isServer }) => { if (!isServer) { From ab233797264813398258696762139e886d3bdfe1 Mon Sep 17 00:00:00 2001 From: Viet Hung Nguyen Date: Sat, 25 Nov 2023 23:24:30 -0800 Subject: [PATCH 2/3] Move blog route --- pages/{blog.js => blog/index.js} | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) rename pages/{blog.js => blog/index.js} (87%) diff --git a/pages/blog.js b/pages/blog/index.js similarity index 87% rename from pages/blog.js rename to pages/blog/index.js index a4f042c..edb9d99 100644 --- a/pages/blog.js +++ b/pages/blog/index.js @@ -1,9 +1,9 @@ import { useLiveQuery } from "next-sanity/preview"; import Card from "components/Card"; -import { readToken } from "./api/sanity.api"; -import { getClient } from "./api/sanity.client"; -import { getPosts, postsQuery } from "./api/sanity.queries"; +import { readToken } from "../api/sanity.api"; +import { getClient } from "../api/sanity.client"; +import { getPosts, postsQuery } from "../api/sanity.queries"; import { Helmet, HeaderNav, Footer } from "@components"; import { useRouter } from "next/router"; @@ -23,10 +23,10 @@ export const getStaticProps = async ({ draftMode = false }) => { export default function Post(props) { const router = useRouter(); const [posts] = useLiveQuery(props.posts, postsQuery); + return (
-

Blog

@@ -47,7 +47,6 @@ export default function Post(props) { )}
-
); } From 79d39445f4d9029b97ba03f67553495368058fb8 Mon Sep 17 00:00:00 2001 From: Viet Hung Nguyen Date: Sat, 25 Nov 2023 23:28:29 -0800 Subject: [PATCH 3/3] Fix Sanity post display --- pages/blog/[slug].js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/pages/blog/[slug].js b/pages/blog/[slug].js index a18e57e..e8eaf1d 100644 --- a/pages/blog/[slug].js +++ b/pages/blog/[slug].js @@ -5,14 +5,13 @@ import { useLiveQuery } from "next-sanity/preview"; import { readToken } from "../api/sanity.api"; import { getClient } from "../api/sanity.client"; import { urlForImage } from "../api/sanity.image"; -import { Helmet, HeaderNav, Footer } from "@components"; +import { Helmet } from "@components"; import { getPost, postBySlugQuery, postSlugsQuery, } from "../api/sanity.queries"; import React from "react"; -import { useRouter } from "next/router"; import clock from "../../public/images/blog-page/clock.svg"; import person from "../../public/images/blog-page/person.svg"; import { formatDate } from "utils/index"; @@ -37,15 +36,13 @@ export const getStaticProps = async ({ draftMode = false, params = {} }) => { }; export default function ProjectSlugRoute(props) { - const router = useRouter(); const [post] = useLiveQuery(props.post, postBySlugQuery, { slug: props.post.slug.current, }); return (
- - +
{post.mainImage ? ( @@ -78,7 +75,6 @@ export default function ProjectSlugRoute(props) {
-