-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathnext-sitemap.config.js
More file actions
86 lines (80 loc) · 2.01 KB
/
next-sitemap.config.js
File metadata and controls
86 lines (80 loc) · 2.01 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
/** @type {import('next-sitemap').IConfig} */
module.exports = {
siteUrl: process.env.SITE_URL || 'https://omshub.org',
generateRobotsTxt: true,
generateIndexSitemap: false,
changefreq: 'daily',
priority: 0.7,
sitemapSize: 5000,
exclude: ['/api/*', '/user/*'],
robotsTxtOptions: {
policies: [
{
userAgent: '*',
allow: '/',
disallow: ['/api/', '/user/'],
},
{
userAgent: 'Googlebot',
allow: '/',
},
],
},
transform: async (config, path) => {
// Higher priority for individual course pages
if (path.startsWith('/course/') && path !== '/course') {
return {
loc: path,
changefreq: 'daily',
priority: 0.9,
lastmod: new Date().toISOString(),
};
}
// Course catalog page - high priority
if (path === '/course') {
return {
loc: path,
changefreq: 'daily',
priority: 0.9,
lastmod: new Date().toISOString(),
};
}
// Home page highest priority
if (path === '/') {
return {
loc: path,
changefreq: 'daily',
priority: 1.0,
lastmod: new Date().toISOString(),
};
}
// Default transform
return {
loc: path,
changefreq: config.changefreq,
priority: config.priority,
lastmod: new Date().toISOString(),
};
},
additionalPaths: async (_config) => {
// Fetch courses from the data repo and add them to sitemap
const result = [];
try {
const response = await fetch(
'https://raw.githubusercontent.com/omshub/data/main/static/courses.json'
);
const courses = await response.json();
for (const courseId of Object.keys(courses)) {
result.push({
loc: `/course/${courseId}`,
changefreq: 'daily',
priority: 0.9,
lastmod: new Date().toISOString(),
});
}
} catch (error) {
console.error('Failed to fetch courses for sitemap:', error);
}
return result;
},
};