Skip to content

Commit c060862

Browse files
dooohunclaude
andauthored
[공통] sitemap.xml 자동 생성 및 robots.txt 강화 (#1258)
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 8ac3601 commit c060862

9 files changed

Lines changed: 147 additions & 5 deletions

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,7 @@ tsconfig.tsbuildinfo
4848
tsconfig.tsbuildinfo
4949
# Sentry Config File
5050
.env.sentry-build-plugin
51+
52+
# next-sitemap 생성 파일 (postbuild)
53+
public/sitemap*.xml
54+
public/robots.txt

.pnp.cjs

Lines changed: 44 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.
3.91 KB
Binary file not shown.
104 KB
Binary file not shown.

next-sitemap.config.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/**
2+
* next-sitemap 설정
3+
* 빌드 후 postbuild 스크립트로 실행되어 public/sitemap*.xml 과 public/robots.txt 를 생성한다.
4+
* stage/prod 환경 분기는 NEXT_PUBLIC_API_PATH 에 'stage' 포함 여부로 판단 (src/static/url.ts 와 동일 규칙).
5+
*/
6+
7+
const IS_STAGE = process.env.NEXT_PUBLIC_API_PATH?.includes('stage');
8+
const SITE_URL = IS_STAGE ? 'https://stage.koreatech.in' : 'https://koreatech.in';
9+
10+
const PRIVATE_PATHS = [
11+
'/auth',
12+
'/auth/*',
13+
'/webview/*',
14+
'/report/*',
15+
'/callvan/add',
16+
'/callvan/chat/*',
17+
'/callvan/notifications',
18+
'/callvan/*/participants',
19+
'/callvan/*/report/*',
20+
'/timetable/modify',
21+
'/clubs/new',
22+
'/clubs/edit/*',
23+
'/clubs/recruitment/edit/*',
24+
'/clubs/*/event/edit/*',
25+
'/lost-item/edit/*',
26+
'/lost-item/report/*',
27+
'/lost-item/chat',
28+
'/store/review/*',
29+
'/store/review/edit/**',
30+
];
31+
32+
/** @type {import('next-sitemap').IConfig} */
33+
export default {
34+
siteUrl: SITE_URL,
35+
generateRobotsTxt: true,
36+
sitemapSize: 5000,
37+
changefreq: 'daily',
38+
priority: 0.7,
39+
exclude: ['/404', '/_error', '/_app', '/_document', ...PRIVATE_PATHS],
40+
robotsTxtOptions: {
41+
policies: [
42+
{
43+
userAgent: '*',
44+
allow: '/',
45+
disallow: [
46+
'/auth',
47+
'/webview',
48+
'/report',
49+
'/callvan/add',
50+
'/callvan/chat',
51+
'/callvan/notifications',
52+
'/timetable/modify',
53+
'/clubs/new',
54+
'/clubs/edit',
55+
'/clubs/recruitment/edit',
56+
'/lost-item/edit',
57+
'/lost-item/report',
58+
'/lost-item/chat',
59+
'/store/review',
60+
],
61+
},
62+
],
63+
},
64+
};

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"scripts": {
3535
"start": "next dev",
3636
"start:serve": "next start",
37-
"build": "tsc && next build",
37+
"build": "tsc && next build && next-sitemap",
3838
"test": "test --coverage",
3939
"sourcemap:clean": "find ./build -name '*.map' -type f -delete",
4040
"lint": "yarn lint:eslint && yarn lint:stylelint",
@@ -81,6 +81,7 @@
8181
"eslint-plugin-react-hooks": "^7.0.1",
8282
"globals": "^16.4.0",
8383
"jest": "^29.7.0",
84+
"next-sitemap": "^4.2.3",
8485
"postcss": "^8.5.11",
8586
"prettier": "^3.6.2",
8687
"sass": "^1.53.0",

public/robots.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

yarn.lock

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2176,6 +2176,13 @@ __metadata:
21762176
languageName: node
21772177
linkType: hard
21782178

2179+
"@corex/deepmerge@npm:^4.0.43":
2180+
version: 4.0.43
2181+
resolution: "@corex/deepmerge@npm:4.0.43"
2182+
checksum: 10/c9ac6163e982e81e3216a9fc7c68cd60b9788ad3b23d7387c9e9741b0274b42dfc332ae74b993e550c95e4256be5ce68045fc55d363aa083344392dc95b50d8b
2183+
languageName: node
2184+
linkType: hard
2185+
21792186
"@csstools/css-parser-algorithms@npm:^2.5.0":
21802187
version: 2.5.0
21812188
resolution: "@csstools/css-parser-algorithms@npm:2.5.0"
@@ -3162,6 +3169,13 @@ __metadata:
31623169
languageName: node
31633170
linkType: hard
31643171

3172+
"@next/env@npm:^13.4.3":
3173+
version: 13.5.11
3174+
resolution: "@next/env@npm:13.5.11"
3175+
checksum: 10/2d34ec742e28b4da54b7bfe62eb27c1c90f927f0dfe387a0af8c1a535faf75d80475e58a33472bdf722bab02349be074935e2bdf512b5fd0a46dab364700dd3d
3176+
languageName: node
3177+
linkType: hard
3178+
31653179
"@next/eslint-plugin-next@npm:^16.0.0":
31663180
version: 16.0.0
31673181
resolution: "@next/eslint-plugin-next@npm:16.0.0"
@@ -10048,6 +10062,7 @@ __metadata:
1004810062
jest: "npm:^29.7.0"
1004910063
lottie-react: "npm:^2.4.1"
1005010064
next: "npm:15.5.18"
10065+
next-sitemap: "npm:^4.2.3"
1005110066
postcss: "npm:^8.5.11"
1005210067
prettier: "npm:^3.6.2"
1005310068
react: "npm:^19.2.6"
@@ -10473,7 +10488,7 @@ __metadata:
1047310488
languageName: node
1047410489
linkType: hard
1047510490

10476-
"minimist@npm:^1.2.0, minimist@npm:^1.2.6":
10491+
"minimist@npm:^1.2.0, minimist@npm:^1.2.6, minimist@npm:^1.2.8":
1047710492
version: 1.2.8
1047810493
resolution: "minimist@npm:1.2.8"
1047910494
checksum: 10/908491b6cc15a6c440ba5b22780a0ba89b9810e1aea684e253e43c4e3b8d56ec1dcdd7ea96dde119c29df59c936cde16062159eae4225c691e19c70b432b6e6f
@@ -10658,6 +10673,23 @@ __metadata:
1065810673
languageName: node
1065910674
linkType: hard
1066010675

10676+
"next-sitemap@npm:^4.2.3":
10677+
version: 4.2.3
10678+
resolution: "next-sitemap@npm:4.2.3"
10679+
dependencies:
10680+
"@corex/deepmerge": "npm:^4.0.43"
10681+
"@next/env": "npm:^13.4.3"
10682+
fast-glob: "npm:^3.2.12"
10683+
minimist: "npm:^1.2.8"
10684+
peerDependencies:
10685+
next: "*"
10686+
bin:
10687+
next-sitemap: bin/next-sitemap.mjs
10688+
next-sitemap-cjs: bin/next-sitemap.cjs
10689+
checksum: 10/8e88c941b5e487584abaa21a31a94d888c8d37e95892cd6b5bdbc121f49435f75c279e97508a7a99d3de0010e833f3769d0c2d0888d9228be4dbd48e031b831c
10690+
languageName: node
10691+
linkType: hard
10692+
1066110693
"next@npm:15.5.18":
1066210694
version: 15.5.18
1066310695
resolution: "next@npm:15.5.18"

0 commit comments

Comments
 (0)