From 68b2570eae9c0be821b345b5da689317de620ddb Mon Sep 17 00:00:00 2001 From: kyuhho Date: Wed, 4 Dec 2024 22:40:51 +0900 Subject: [PATCH 1/7] chore: remove admin url (#421) --- src/Router.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Router.tsx b/src/Router.tsx index f784938d..b5c6b9ff 100644 --- a/src/Router.tsx +++ b/src/Router.tsx @@ -60,11 +60,11 @@ import SellerCalculateManagement from 'pages/Seller/SellerCalculateManagement'; const Router = () => { return ( - {/* admin */} - } - /> + /> */} {/* minder(buyer) */} } /> } /> From 2050cf203826dc710a761c6cf8e94e8b9bc97867 Mon Sep 17 00:00:00 2001 From: kyuhho Date: Wed, 4 Dec 2024 22:41:02 +0900 Subject: [PATCH 2/7] feat: init sitemap (#421) --- public/sitemap.xml | 72 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 public/sitemap.xml diff --git a/public/sitemap.xml b/public/sitemap.xml new file mode 100644 index 00000000..847a0c09 --- /dev/null +++ b/public/sitemap.xml @@ -0,0 +1,72 @@ + + + + + https://sharemindapp.com/ + monthly + 0.3 + + + https://sharemindapp.com/share + hourly + 1.0 + + + https://sharemindapp.com/open-consult + always + 1.0 + + + https://sharemindapp.com/open-consult/likes + always + 0.8 + + + https://sharemindapp.com/open-consult/recents + always + 0.8 + + + https://sharemindapp.com/categorySearch + daily + 0.7 + + + https://sharemindapp.com/service + never + 0.8 + + + https://sharemindapp.com/service-unavailable + monthly + 0.5 + + + + + + https://sharemindapp.com/open-consult/101 + weekly + 0.7 + + + https://sharemindapp.com/open-consult/102 + weekly + 0.7 + + + https://sharemindapp.com/profile/1 + monthly + 0.7 + + + https://sharemindapp.com/profile/2 + monthly + 0.7 + + + https://sharemindapp.com/minder/open-consult/789 + weekly + 0.6 + + From 24a2f49b1db3c8a04aaa366598b81c4c99fb25ec Mon Sep 17 00:00:00 2001 From: kyuhho Date: Wed, 4 Dec 2024 23:15:54 +0900 Subject: [PATCH 3/7] chore: fix deprecated api naming (#421) --- src/api/patch.ts | 7 +++++-- src/pages/Buyer/BuyerAvailCounselor.tsx | 4 ++-- src/pages/Buyer/BuyerCategoryResult.tsx | 4 ++-- src/pages/Buyer/BuyerHome.tsx | 4 ++-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/api/patch.ts b/src/api/patch.ts index db5300b1..05ad4440 100644 --- a/src/api/patch.ts +++ b/src/api/patch.ts @@ -35,8 +35,11 @@ export const patchAuthSignOut = async (body: any) => //Counselor Controller //카테고리/들준마 상담사 리스트 반환 -export const patchCounselorsAll = async (sortType: string, body: any) => - await patchPublicInstance(`/counselors/all?sortType=${sortType}`, body); +export const patchCounselorsAllDeprecated = async ( + sortType: string, + body: any, +) => await patchPublicInstance(`/counselors/all?sortType=${sortType}`, body); + //LetterMessage Controller //Message 최초 생성 export const patchLetterMessage = async (body: any) => diff --git a/src/pages/Buyer/BuyerAvailCounselor.tsx b/src/pages/Buyer/BuyerAvailCounselor.tsx index ac8404b8..7c885dfe 100644 --- a/src/pages/Buyer/BuyerAvailCounselor.tsx +++ b/src/pages/Buyer/BuyerAvailCounselor.tsx @@ -10,7 +10,7 @@ import { sortList } from 'utils/constant'; import { useRecoilState, useSetRecoilState } from 'recoil'; import { isSortModalOpenState, scrollLockState } from 'utils/atom'; import { SearchResultData } from 'utils/type'; -import { patchCounselorsAll } from 'api/patch'; +import { patchCounselorsAllDeprecated } from 'api/patch'; import { ConverSortType } from 'utils/convertSortType'; import { AvailCounselorSearchResults } from 'components/Buyer/BuyerAvailCounselor/AvailCounselorSearchResult'; import useIntersectionObserver from 'hooks/useIntersectionObserver'; @@ -61,7 +61,7 @@ export const BuyerAvailCounselor = () => { index: pageIndex, }; const sortTypeString: string = ConverSortType(sortType); - const res: any = await patchCounselorsAll(sortTypeString, body); + const res: any = await patchCounselorsAllDeprecated(sortTypeString, body); if (res.status === 200) { if (res.data.length !== 0) { if (pageIndex === 0) { diff --git a/src/pages/Buyer/BuyerCategoryResult.tsx b/src/pages/Buyer/BuyerCategoryResult.tsx index ea0e8a73..c4ba9722 100644 --- a/src/pages/Buyer/BuyerCategoryResult.tsx +++ b/src/pages/Buyer/BuyerCategoryResult.tsx @@ -14,7 +14,7 @@ import { searchKeywordState, } from 'utils/atom'; import { ConverSortType } from 'utils/convertSortType'; -import { patchCounselorsAll } from 'api/patch'; +import { patchCounselorsAllDeprecated } from 'api/patch'; import { SearchResultData } from 'utils/type'; import { CategorySearchResults } from 'components/Buyer/BuyerCategoryResult/CategorySearchResult'; @@ -68,7 +68,7 @@ export const BuyerCategoryResult = () => { index: pageIndex, }; const sortTypeString: string = ConverSortType(sortType); - const res: any = await patchCounselorsAll(sortTypeString, body); + const res: any = await patchCounselorsAllDeprecated(sortTypeString, body); if (res.status === 200) { if (res.data.length !== 0) { if (pageIndex === 0) { diff --git a/src/pages/Buyer/BuyerHome.tsx b/src/pages/Buyer/BuyerHome.tsx index 71879a4d..dae47855 100644 --- a/src/pages/Buyer/BuyerHome.tsx +++ b/src/pages/Buyer/BuyerHome.tsx @@ -8,7 +8,7 @@ import styled from 'styled-components'; import HomeAboutFooterSection from 'components/Common/HomeAboutFooterSection'; import { SearchResultData } from 'utils/type'; import { useEffect, useState } from 'react'; -import { patchCounselorsAll } from 'api/patch'; +import { patchCounselorsAllDeprecated } from 'api/patch'; import { getRandomCounselors } from 'api/get'; // @@ -30,7 +30,7 @@ export const BuyerHome = () => { const body = { index: 0, }; - const res: any = await patchCounselorsAll('POPULARITY', body); + const res: any = await patchCounselorsAllDeprecated('POPULARITY', body); if (res.status === 200) { if (res.data.length > 0) { setSearchData(res.data); From bee7dafcf9dfe18967ef4fb3de0f2c2f0ac8cfc6 Mon Sep 17 00:00:00 2001 From: kyuhho Date: Thu, 5 Dec 2024 00:28:40 +0900 Subject: [PATCH 4/7] feat: apply generating script for sitemap (#421) --- generateSitemap.mjs | 76 +++++++++++++++++++++++++++++++++++++++++++++ package-lock.json | 32 +++++++++++++++++++ package.json | 1 + public/robots.txt | 2 ++ public/sitemap.xml | 73 +------------------------------------------ src/api/patch.ts | 3 ++ 6 files changed, 115 insertions(+), 72 deletions(-) create mode 100644 generateSitemap.mjs diff --git a/generateSitemap.mjs b/generateSitemap.mjs new file mode 100644 index 00000000..4d6f6f5b --- /dev/null +++ b/generateSitemap.mjs @@ -0,0 +1,76 @@ +import fs from 'fs'; +import { SitemapStream } from 'sitemap'; +import axios from 'axios'; +import { configDotenv } from 'dotenv'; + +// load env file +configDotenv(); + +const generateSitemap = async () => { + const hostname = 'https://sharemindapp.com'; + + // 정적 경로 + const staticRoutes = [ + { url: '/', changefreq: 'monthly', priority: 0.3 }, + { url: '/share', changefreq: 'hourly', priority: 1.0 }, + { url: '/open-consult', changefreq: 'always', priority: 1.0 }, + { url: '/open-consult/likes', changefreq: 'always', priority: 0.8 }, + { url: '/open-consult/recents', changefreq: 'always', priority: 0.8 }, + { url: '/categorySearch', changefreq: 'daily', priority: 0.7 }, + { url: '/service', changefreq: 'never', priority: 0.8 }, + { url: '/service-unavailable', changefreq: 'monthly', priority: 0.5 }, + ]; + + // 동적 경로 + const dynamicRoutes = []; + + try { + const counselorAllResponse = await axios.patch( + process.env.REACT_APP_API_URL + 'counselors/all?sortType=POPULARITY', + { + index: 0, + }, + { + headers: { + 'Content-Type': 'application/json', + }, + }, + ); + + const profileDynamicRoutes = counselorAllResponse.data.map((counselor) => ({ + url: `/profile/${counselor.counselorId}`, + changefreq: 'daily', + priority: 0.7, + })); + + dynamicRoutes.push(...profileDynamicRoutes); + } catch (error) { + console.log(error); + } + + // Sitemap 생성 + const sitemap = new SitemapStream({ hostname }); + const writeStream = fs.createWriteStream('./public/sitemap.xml'); + + sitemap.pipe(writeStream); + + // 정적 경로 추가 + staticRoutes.forEach((route) => sitemap.write(route)); + + // 동적 경로 추가 + dynamicRoutes.forEach((route) => sitemap.write(route)); + + // 종료 + sitemap.end(); + + // 파일 쓰기 완료 이벤트 + writeStream.on('finish', () => { + console.log('Sitemap successfully written to file!'); + }); + + writeStream.on('error', (err) => { + console.error('Error writing sitemap:', err); + }); +}; + +generateSitemap(); diff --git a/package-lock.json b/package-lock.json index b05f6420..d3d1153e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -35,6 +35,7 @@ "react-use": "^17.5.0", "recoil": "^0.7.7", "recoil-persist": "^5.1.0", + "sitemap": "^8.0.0", "sockjs-client": "^1.6.1", "styled-components": "^6.1.8", "styled-normalize": "^8.1.0", @@ -4733,6 +4734,14 @@ "resolved": "https://registry.npmjs.org/@types/retry/-/retry-0.12.0.tgz", "integrity": "sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA==" }, + "node_modules/@types/sax": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/@types/sax/-/sax-1.2.7.tgz", + "integrity": "sha512-rO73L89PJxeYM3s3pPPjiPgVVcymqU490g0YO5n5By0k2Erzj6tay/4lr1CHAAU4JyOWd1rpQ8bCf6cZfHU96A==", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/scheduler": { "version": "0.16.8", "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.8.tgz", @@ -16565,6 +16574,29 @@ "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==" }, + "node_modules/sitemap": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/sitemap/-/sitemap-8.0.0.tgz", + "integrity": "sha512-+AbdxhM9kJsHtruUF39bwS/B0Fytw6Fr1o4ZAIAEqA6cke2xcoO2GleBw9Zw7nRzILVEgz7zBM5GiTJjie1G9A==", + "dependencies": { + "@types/node": "^17.0.5", + "@types/sax": "^1.2.1", + "arg": "^5.0.0", + "sax": "^1.2.4" + }, + "bin": { + "sitemap": "dist/cli.js" + }, + "engines": { + "node": ">=14.0.0", + "npm": ">=6.0.0" + } + }, + "node_modules/sitemap/node_modules/@types/node": { + "version": "17.0.45", + "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.45.tgz", + "integrity": "sha512-w+tIMs3rq2afQdsPJlODhoUEKzFP1ayaoyl1CcnwtIlsVe7K7bA1NGm4s3PraqTLlXnbIN84zuBlxBWo1u9BLw==" + }, "node_modules/slash": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", diff --git a/package.json b/package.json index d2e8e68a..b9c90622 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "react-use": "^17.5.0", "recoil": "^0.7.7", "recoil-persist": "^5.1.0", + "sitemap": "^8.0.0", "sockjs-client": "^1.6.1", "styled-components": "^6.1.8", "styled-normalize": "^8.1.0", diff --git a/public/robots.txt b/public/robots.txt index e9e57dc4..a66d087d 100644 --- a/public/robots.txt +++ b/public/robots.txt @@ -1,3 +1,5 @@ # https://www.robotstxt.org/robotstxt.html User-agent: * Disallow: + +Sitemap: https://sharemindapp.com/sitemap.xml \ No newline at end of file diff --git a/public/sitemap.xml b/public/sitemap.xml index 847a0c09..d2558e46 100644 --- a/public/sitemap.xml +++ b/public/sitemap.xml @@ -1,72 +1 @@ - - - - - https://sharemindapp.com/ - monthly - 0.3 - - - https://sharemindapp.com/share - hourly - 1.0 - - - https://sharemindapp.com/open-consult - always - 1.0 - - - https://sharemindapp.com/open-consult/likes - always - 0.8 - - - https://sharemindapp.com/open-consult/recents - always - 0.8 - - - https://sharemindapp.com/categorySearch - daily - 0.7 - - - https://sharemindapp.com/service - never - 0.8 - - - https://sharemindapp.com/service-unavailable - monthly - 0.5 - - - - - - https://sharemindapp.com/open-consult/101 - weekly - 0.7 - - - https://sharemindapp.com/open-consult/102 - weekly - 0.7 - - - https://sharemindapp.com/profile/1 - monthly - 0.7 - - - https://sharemindapp.com/profile/2 - monthly - 0.7 - - - https://sharemindapp.com/minder/open-consult/789 - weekly - 0.6 - - +https://sharemindapp.com/monthly0.3https://sharemindapp.com/sharehourly1.0https://sharemindapp.com/open-consultalways1.0https://sharemindapp.com/open-consult/likesalways0.8https://sharemindapp.com/open-consult/recentsalways0.8https://sharemindapp.com/categorySearchdaily0.7https://sharemindapp.com/servicenever0.8https://sharemindapp.com/service-unavailablemonthly0.5https://sharemindapp.com/profile/34daily0.7https://sharemindapp.com/profile/45daily0.7https://sharemindapp.com/profile/53daily0.7https://sharemindapp.com/profile/71daily0.7 \ No newline at end of file diff --git a/src/api/patch.ts b/src/api/patch.ts index 05ad4440..17d2bb56 100644 --- a/src/api/patch.ts +++ b/src/api/patch.ts @@ -40,6 +40,9 @@ export const patchCounselorsAllDeprecated = async ( body: any, ) => await patchPublicInstance(`/counselors/all?sortType=${sortType}`, body); +export const patchCounselorsAll = async (sortType: string, body: any) => + await axiosPatch(`/counselors/all?sortType=${sortType}`, body); + //LetterMessage Controller //Message 최초 생성 export const patchLetterMessage = async (body: any) => From b865c0906f5a6bb8f07aa052f555b59c77f2c6c3 Mon Sep 17 00:00:00 2001 From: kyuhho Date: Thu, 5 Dec 2024 11:42:45 +0900 Subject: [PATCH 5/7] feat: add hot list to generateSitemap --- generateSitemap.mjs | 25 +++++++++++++++++++++++++ public/sitemap.xml | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/generateSitemap.mjs b/generateSitemap.mjs index 4d6f6f5b..fbc0647c 100644 --- a/generateSitemap.mjs +++ b/generateSitemap.mjs @@ -48,6 +48,31 @@ const generateSitemap = async () => { console.log(error); } + try { + const likesResponse = await axios.get( + process.env.REACT_APP_API_URL + + 'posts/customers/public/likes?postId=0&finishedAt=' + + new Date().toISOString().slice(0, 19), + { + headers: { + 'Content-Type': 'application/json', + }, + }, + ); + + console.log(likesResponse); + + const likesDynamicRoutes = likesResponse.data.map((post) => ({ + url: `/open-consult/${post.postId}`, + changefreq: 'daily', + priority: 0.7, + })); + + dynamicRoutes.push(...likesDynamicRoutes); + } catch (error) { + console.log(error); + } + // Sitemap 생성 const sitemap = new SitemapStream({ hostname }); const writeStream = fs.createWriteStream('./public/sitemap.xml'); diff --git a/public/sitemap.xml b/public/sitemap.xml index d2558e46..2f7c2a8d 100644 --- a/public/sitemap.xml +++ b/public/sitemap.xml @@ -1 +1 @@ -https://sharemindapp.com/monthly0.3https://sharemindapp.com/sharehourly1.0https://sharemindapp.com/open-consultalways1.0https://sharemindapp.com/open-consult/likesalways0.8https://sharemindapp.com/open-consult/recentsalways0.8https://sharemindapp.com/categorySearchdaily0.7https://sharemindapp.com/servicenever0.8https://sharemindapp.com/service-unavailablemonthly0.5https://sharemindapp.com/profile/34daily0.7https://sharemindapp.com/profile/45daily0.7https://sharemindapp.com/profile/53daily0.7https://sharemindapp.com/profile/71daily0.7 \ No newline at end of file +https://sharemindapp.com/monthly0.3https://sharemindapp.com/sharehourly1.0https://sharemindapp.com/open-consultalways1.0https://sharemindapp.com/open-consult/likesalways0.8https://sharemindapp.com/open-consult/recentsalways0.8https://sharemindapp.com/categorySearchdaily0.7https://sharemindapp.com/servicenever0.8https://sharemindapp.com/service-unavailablemonthly0.5https://sharemindapp.com/profile/34daily0.7https://sharemindapp.com/profile/38daily0.7https://sharemindapp.com/profile/43daily0.7https://sharemindapp.com/profile/73daily0.7https://sharemindapp.com/open-consult/2daily0.7https://sharemindapp.com/open-consult/1daily0.7 \ No newline at end of file From deeb46e97e68fa0e62ac55996552e6dd5e80c61e Mon Sep 17 00:00:00 2001 From: kyuhho Date: Thu, 5 Dec 2024 11:51:14 +0900 Subject: [PATCH 6/7] feat: apply to build script --- generateSitemap.mjs | 2 -- package.json | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/generateSitemap.mjs b/generateSitemap.mjs index fbc0647c..2f3855b9 100644 --- a/generateSitemap.mjs +++ b/generateSitemap.mjs @@ -60,8 +60,6 @@ const generateSitemap = async () => { }, ); - console.log(likesResponse); - const likesDynamicRoutes = likesResponse.data.map((post) => ({ url: `/open-consult/${post.postId}`, changefreq: 'daily', diff --git a/package.json b/package.json index b9c90622..fc04ea91 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "scripts": { "start": "env-cmd -f .env.development react-scripts start", "start:prod": "env-cmd -f .env react-scripts start", - "build": "react-scripts build", + "build": "node generateSitemap.mjs && react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject" }, From 5a8877b169bda9179b0ff499ff40020cac8c2582 Mon Sep 17 00:00:00 2001 From: kyuhho Date: Thu, 5 Dec 2024 11:56:12 +0900 Subject: [PATCH 7/7] feat: add meta tag for google search console --- public/index.html | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/public/index.html b/public/index.html index d94dc3b5..f466b1fd 100644 --- a/public/index.html +++ b/public/index.html @@ -26,6 +26,13 @@ name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" /> + + + +