forked from weijunext/nextjs-learn-demos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext-sitemap.config.js
61 lines (61 loc) · 1.86 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
61
/**
* @type {import('next-sitemap').IConfig}
* @see https://github.com/iamvishnusankar/next-sitemap#readme
*/
module.exports = {
siteUrl: 'https://nextjs.weijunext.com',
changefreq: 'daily',
priority: 0.7,
exclude: ['/server-sitemap.xml', '/404'],
generateRobotsTxt: true,
sitemapSize: 5000, // 站点超过5000个,拆分到多个文件
transform: async (config, path) => {
return {
loc: 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 ?? [],
}
},
additionalPaths: async (config) => [
// 这个版本的next-sitemap无法把app router的静态目录加载进来,所以在这里手动添加了
await config.transform(config, '/'),
await config.transform(config, '/hooks/useSyncExternalStore'),
await config.transform(config, '/hooks/useRef'),
await config.transform(config, '/hooks/useMemo'),
await config.transform(config, '/hooks/useLayoutEffect'),
await config.transform(config, '/hooks/useImperativeHandle'),
await config.transform(config, '/hooks/useEffect'),
await config.transform(config, '/hooks/useDeferredValue'),
await config.transform(config, '/hooks'),
await config.transform(config, '/fake-membership'),
],
robotsTxtOptions: {
additionalSitemaps: [
'https://nextjs.weijunext.com/sitemap.xml',
],
policies: [
{
userAgent: '*',
allow: '/',
},
{
userAgent: 'AhrefsBot',
disallow: ['/'],
},
{
userAgent: 'SemrushBot',
disallow: ['/'],
},
{
userAgent: 'MJ12bot',
disallow: ['/'],
},
{
userAgent: 'DotBot',
disallow: ['/'],
},
],
},
};