-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnext-sitemap.config.js
39 lines (35 loc) · 1.21 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
let siteUrl = process.env.NEXT_PUBLIC_SITE_URL || 'https://www.localhost:3000';
if (process.env.BASE_DEPLOY_PATH) {
siteUrl = `${siteUrl}${process.env.BASE_DEPLOY_PATH}`;
}
const policy = {
userAgent: '*'
};
if (process.env.NEXT_PUBLIC_NODE_ENV !== 'production') {
policy.disallow = '/';
policy.xRobotsTag = 'noindex, nofollow';
}
/** @type {import('next-sitemap').IConfig} */
module.exports = {
siteUrl,
generateRobotsTxt: true,
robotsTxtOptions: {
policies: [policy]
},
transform: (config, path) => {
// Ignore /dashboard page, Configure your own pages from here which you don't want to be crawled
if (path.match(`\\/.*\\/(dashboard)\\.*`)) {
return null;
}
// Use default transformation for all other cases
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 ?? []
};
},
sourceDir: process.env.NODE_ENV === 'development' ? '.next-dev' : '.next',
outDir: 'public'
};