-
-
Notifications
You must be signed in to change notification settings - Fork 470
Expand file tree
/
Copy pathgenerate-sitemap.js
More file actions
26 lines (19 loc) · 739 Bytes
/
generate-sitemap.js
File metadata and controls
26 lines (19 loc) · 739 Bytes
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
const { SitemapStream } = require('sitemap');
const { createWriteStream } = require('fs');
const path = require('path');
const pages = [
{ url: '/', changefreq: 'daily', priority: 1.0 },
{ url: '/opportunities', changefreq: 'weekly', priority: 0.8 },
];
async function generateSitemap() {
const writeStream = createWriteStream(path.resolve(__dirname, 'public', 'sitemap.xml'));
const sitemap = new SitemapStream({ hostname: 'https://www.devdisplay.org' });
sitemap.pipe(writeStream).on('finish', () => {
console.log('Sitemap generated successfully');
});
pages.forEach((page) => sitemap.write(page));
sitemap.end();
}
generateSitemap().catch((error) => {
console.error('Error generating sitemap:', error);
});