-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext-sitemap.config.js
61 lines (52 loc) · 1.94 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} */
module.exports = {
siteUrl: process.env.SITE_URL ?? '.',
generateRobotsTxt: true,
sitemapSize: 10,
// default options
changefreq: "monthly",
priority: .9,
autoLastmod: false,
// https://www.contentpowered.com/blog/xml-sitemap-priority-changefreq/
// 0.0 - 0.3: Old news posts, outdated guides, irrelevant pages you nevertheless don't want to delete, merge, or update.
// 0.4 - 0.7: Articles, blog posts, category pages, FAQs, system pages. The bulk of your site's content falls into this range.
// 0.8 - 1.0: Extremely important content, such as your homepage, major category pages, product pages, and subdomain indexes.
robotsTxtOptions: {
policies: [
{
userAgent: '*',
allow: '/'
}
]
},
transform: async (config, path) => {
switch (path) {
case '/':
config.priority = 1;
config.changefreq = "yearly";
break;
case "/contact":
config.priority = .8;
config.changefreq = "monthly";
break;
case "/projects":
config.priority = .9;
config.changefreq = "monthly";
break;
default:
if ( path.match(/^\/projects\/[^\\ /]+$/) ) { // if the path is for a project
config.priority = .6;
config.changefreq = "yearly";
//config.lastmod = new Date().toISOString(); // idk how to load the data from here
}
break;
}
return {
loc: path,
changefreq: config.changefreq,
priority: config.priority,
lastmod: config.lastmod ?? config.autoLastmod ? new Date().toISOString() : undefined,
alternateRefs: config.alternateRefs ?? [],
}
},
}