From b33ca72d0679762be9f506557e733242dbcaa1b0 Mon Sep 17 00:00:00 2001 From: seokho10007 <sukho1007@naver.com> Date: Sat, 7 Oct 2023 00:16:41 +0900 Subject: [PATCH 1/3] =?UTF-8?q?chore:=20=ED=99=98=EA=B2=BD=20=EB=B3=80?= =?UTF-8?q?=EC=88=98=20=EC=9D=B4=EB=A6=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/constant/env.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/constant/env.ts b/src/utils/constant/env.ts index 77e660b..f603685 100644 --- a/src/utils/constant/env.ts +++ b/src/utils/constant/env.ts @@ -1,7 +1,7 @@ const isProd = process.env.NODE_ENV === "production"; const TOKEN_EXPIRED = "jwt expired"; -const API_URL = process.env.API_URL as string; +const API_URL = process.env.NEXT_PUBLIC_API_URL as string; const HOST = process.env.HOST as string; const GOOGLE_SITE_VERIFICATION = isProd ? process.env.GOOGLE_SITE_VERIFICATION : ""; const GA_TRACKING_ID = isProd ? process.env.NEXT_PUBLIC_GA_ID : ""; From a556a9d5924b7e7b2035a2bb8e2a713b8117fbad Mon Sep 17 00:00:00 2001 From: seokho10007 <sukho1007@naver.com> Date: Sat, 7 Oct 2023 00:17:01 +0900 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20sitemap=20=EC=83=9D=EC=84=B1?= =?UTF-8?q?=EC=8B=9C=20axios=EA=B0=80=20=EC=95=84=EB=8B=8C=20fetch=20?= =?UTF-8?q?=EC=82=AC=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/sitemap.ts | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/src/app/sitemap.ts b/src/app/sitemap.ts index 22774c3..0c1253a 100644 --- a/src/app/sitemap.ts +++ b/src/app/sitemap.ts @@ -1,20 +1,31 @@ -import { HOST } from "@utils/constant/env"; -import { getPosts } from "@/apis/post"; +import { MetadataRoute } from "next"; -const ROUTES = ["", "/project", "/series", "/about"]; +import { API_URL, HOST } from "@utils/constant/env"; +import { IPost } from "@/types"; -const sitemap = async () => { - const posts = (await getPosts({ sort: 1, limit: 9999 })).map(({ nid, createdAt }) => ({ - url: `${HOST}/post/${nid}`, - lastModified: createdAt, - })); +async function sitemap(): Promise<MetadataRoute.Sitemap> { + const query = new URLSearchParams({ sort: "1", limit: "9999" }).toString(); + const url = `${API_URL}/posts?${query}`; - const routes = ROUTES.map((route) => ({ - url: `${HOST}${route}`, - lastModified: new Date().toISOString(), - })); + try { + const res = await fetch(url, { method: "GET", cache: "no-store" }); - return [...routes, ...posts]; -}; + const posts = (await res.json()) as IPost[]; + + const postsSiteMap = posts.map(({ nid, createdAt }) => ({ + url: `${HOST}/post/${nid}`, + lastModified: createdAt, + })); + + const routes = ["", "/project", "/series", "/about"].map((route) => ({ + url: `${HOST}${route}`, + lastModified: new Date().toISOString(), + })); + + return [...routes, ...postsSiteMap]; + } catch (e) { + return []; + } +} export default sitemap; From 55fa48ac95163322647c6a744c6aea147ccc9a5c Mon Sep 17 00:00:00 2001 From: seokho10007 <sukho1007@naver.com> Date: Sat, 7 Oct 2023 00:17:36 +0900 Subject: [PATCH 3/3] =?UTF-8?q?feat:=20page=20=EC=86=8C=EA=B0=9C=20title?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/about/page.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/about/page.ts b/src/app/about/page.ts index dfa6367..8f13e36 100644 --- a/src/app/about/page.ts +++ b/src/app/about/page.ts @@ -5,7 +5,7 @@ import { siteMetadata } from "@utils/constant/metadata"; export const generateMetadata = (): Metadata => { const { openGraph, ...rest } = generateDefaultMetadata({ - title: "About", + title: "안녕하세요! 개발자 지석호입니다.", description: siteMetadata.description, url: `${siteMetadata.siteUrl}/about`, });