forked from lingdojo/kana-dojo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext-sitemap.config.js
More file actions
171 lines (161 loc) · 3.66 KB
/
next-sitemap.config.js
File metadata and controls
171 lines (161 loc) · 3.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
import fs from 'node:fs';
import path from 'node:path';
function getAcademyPostPaths() {
const postsDir = path.join(
process.cwd(),
'features',
'Blog',
'content',
'posts',
'en',
);
const paths = [];
function walk(dir) {
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
const fullPath = path.join(dir, entry.name);
if (entry.isDirectory()) {
walk(fullPath);
continue;
}
if (entry.isFile() && entry.name.endsWith('.mdx')) {
paths.push(`/academy/${path.basename(entry.name, '.mdx')}`);
}
}
}
if (fs.existsSync(postsDir)) {
walk(postsDir);
}
return paths;
}
/** @type {import('next-sitemap').IConfig} */
const sitemapConfig = {
siteUrl: process.env.SITE_URL || 'https://kanadojo.com',
generateRobotsTxt: true,
generateIndexSitemap: false,
changefreq: 'weekly',
priority: 0.7,
sitemapSize: 5000,
additionalPaths: async config => {
const academyPaths = getAcademyPostPaths();
const corePaths = [
'/',
'/kana',
'/kanji',
'/vocabulary',
'/translate',
'/translate/english-to-japanese',
'/translate/japanese-to-english',
'/translate/romaji',
'/conjugate',
'/academy',
'/faq',
'/hiragana-practice',
'/katakana-practice',
'/kanji-practice',
'/jlpt/n5',
'/jlpt/n4',
'/jlpt/n3',
'/resources',
'/anki-converter',
'/kana-chart',
];
const uniquePaths = [...new Set([...corePaths, ...academyPaths])];
return uniquePaths.map(loc => ({
loc,
changefreq: config.changefreq,
priority:
loc.startsWith('/translate') || loc === '/' || loc === '/conjugate'
? 0.9
: config.priority,
lastmod: config.autoLastmod ? new Date().toISOString() : undefined,
}));
},
exclude: [
'/api/*',
'/_next/*',
'/en',
'/es',
'/en/*',
'/es/*',
'/tools/*',
'/*/train/*',
],
robotsTxtOptions: {
policies: [
{
userAgent: '*',
allow: '/',
},
{
userAgent: 'GPTBot',
allow: '/',
},
{
userAgent: 'ChatGPT-User',
allow: '/',
},
{
userAgent: 'Claude-Web',
allow: '/',
},
{
userAgent: 'anthropic-ai',
allow: '/',
},
{
userAgent: 'PerplexityBot',
allow: '/',
},
{
userAgent: 'Google-Extended',
allow: '/',
},
{
userAgent: 'CCBot',
allow: '/',
},
{
userAgent: 'Applebot',
allow: '/',
},
{
userAgent: 'Amazonbot',
allow: '/',
},
],
additionalSitemaps: [],
},
transform: async (config, path) => {
const priorities = {
'/': 1.0,
'/translate': 0.9,
'/translate/english-to-japanese': 0.85,
'/translate/japanese-to-english': 0.85,
'/translate/romaji': 0.85,
'/kana': 0.9,
'/kanji': 0.9,
'/vocabulary': 0.9,
'/conjugate': 0.9,
'/anki-converter': 0.85,
'/academy': 0.85,
'/resources': 0.85,
};
const changefreqs = {
'/': 'daily',
'/translate': 'daily',
'/translate/english-to-japanese': 'weekly',
'/translate/japanese-to-english': 'weekly',
'/translate/romaji': 'weekly',
'/conjugate': 'daily',
'/academy': 'daily',
'/resources': 'daily',
};
return {
loc: path,
changefreq: changefreqs[path] || config.changefreq,
priority: priorities[path] || config.priority,
lastmod: config.autoLastmod ? new Date().toISOString() : undefined,
};
},
};
export default sitemapConfig;