Skip to content

Commit a93448d

Browse files
committed
Add create sitemap.xml script.
1 parent a7d6017 commit a93448d

File tree

3 files changed

+289
-1
lines changed

3 files changed

+289
-1
lines changed

build/sitemap.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const path = require('path');
2+
const fs = require('fs-extra');
3+
const SitemapGenerator = require('sitemap-generator');
4+
5+
const xmlFile = path.join(process.cwd(), '.deploy/sitemap.xml')
6+
const generator = SitemapGenerator('http://192.168.31.69:1987', {
7+
maxDepth: 0,
8+
filepath: xmlFile,
9+
maxEntriesPerFile: 50000,
10+
stripQuerystring: true,
11+
decodeResponses: true,
12+
});
13+
14+
// register event listeners
15+
generator.on('done', async () => {
16+
const str = await fs.readFileSync(xmlFile);
17+
const newStr = str.toString().replace(/http\:\/\/192\.168\.31\.69\:1987/g, 'https://wangchujiang.com/linux-command');
18+
await fs.outputFile(xmlFile, newStr);
19+
console.log('sitemaps created!')
20+
});
21+
22+
// start the crawler
23+
generator.start();

0 commit comments

Comments
 (0)