forked from cdnjs/new-website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.js
executable file
·34 lines (25 loc) · 869 Bytes
/
update.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
#!/usr/bin/env node
var _ = require('lodash');
var fs = require('fs');
var pkgMeta = JSON.parse(fs.readFileSync('public/packages.min.json', 'utf8')).packages;
// Generate sitemap
var pages = [
'https://cdnjs.com/',
'https://cdnjs.com/about',
'https://cdnjs.com/login',
'https://cdnjs.com/register'
];
var xml = '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
var librariePages = _.map(pkgMeta, function(library) {
return 'https://cdnjs.com/libraries/' + library.name;
});
pages = pages.concat(librariePages);
var librarieNewsPages = _.map(pkgMeta, function(library) {
return 'https://cdnjs.com/libraries/' + library.name + '/news';
});
pages = pages.concat(librarieNewsPages);
_.each(pages, function(page) {
xml += '<url><loc>' + page + '</loc></url>';
});
xml += '</urlset>';
fs.writeFileSync('public/sitemap.xml', xml, 'utf8');