-
Notifications
You must be signed in to change notification settings - Fork 179
/
next-sitemap.config.js
49 lines (38 loc) · 1.23 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
/** @type {import('next-sitemap').IConfig} */
const fs = require('fs');
var traverseFolder = function (dir) {
var results = [];
var list = fs.readdirSync(dir);
list.forEach(function (file) {
var filex = dir + "/" + file;
var stat = fs.statSync(filex);
if (stat && stat.isDirectory()) {
/* Add the directory to results, but do not recurse into it */
filex = filex.replace(/public/g, "").replace(/\/?$/, '/');
results.push(filex);
}
});
return results;
};
const config = {
siteUrl: 'https://ballerina.io/',
generateRobotsTxt: false, // (optional)
sitemapSize: 5000,
generateIndexSitemap: false,
additionalPaths: async (config) => {
const result = []
// using transformation from the current configuration
// result.push(await config.transform(config, '/additional-page-3'))
const additionalUrls = traverseFolder("public/spec/lang");
async function asyncCall(element) {
result.push(await config.transform(config, element))
}
additionalUrls.forEach(element => {
asyncCall(element);
});
return result
}
// ...other options
}
// export default config
module.exports = config;