-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext-sitemap.config.js
60 lines (59 loc) · 1.52 KB
/
next-sitemap.config.js
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
/** @type {import('next-sitemap').IConfig} */
module.exports = {
siteUrl: 'https://blog.tsuizen.cn',
changefreq: 'daily',
priority: 1,
sitemapSize: 5000,
generateRobotsTxt: true,
// exclude: ['/protected-page', '/awesome/secret-page'],
// alternateRefs: [
// {
// href: 'https://blog.tsuizen.cn',
// hreflang: 'cn'
// }
// ],
// Default transformation function
transform: async (config, path) => {
const result = {
loc: 'https://blog.tsuizen.cn' + path, // => this will be exported as http(s)://<config.siteUrl>/<path>
changefreq: config.changefreq,
priority: config.priority,
lastmod: config.autoLastmod ? new Date().toISOString() : undefined,
alternateRefs: config.alternateRefs ?? []
};
if (path.startsWith('/tag')) {
result.priority = 0.6;
}
if (path.startsWith('/posts')) {
result.priority = 1;
this.changefreq = 'always';
}
if (path.startsWith('/category')) {
result.priority = 0.4;
}
if (path.startsWith('/archives')) {
result.priority = 0.3;
}
return result;
},
// additionalPaths: async (config) => [
// await config.transform(config, '/additional-page')
// ],
robotsTxtOptions: {
policies: [
{
userAgent: '*',
allow: '/'
},
{
userAgent: 'test-bot',
allow: ['/path', '/path-2']
}
// {
// userAgent: 'black-listed-bot',
// disallow: ['/sub-path-1', '/path-2']
// }
],
additionalSitemaps: []
}
};