-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmakeSearchIndex.js
33 lines (30 loc) · 1010 Bytes
/
makeSearchIndex.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
/** @ts-ignore */
/** @type {import('flexsearch')['default']} */
const FlexSearch = require('flexsearch');
const {existsSync, rmdirSync, readFileSync, copyFile} = require('fs');
const {poindexter} = require('poindexter');
process.chdir(__dirname);
// rmdirSync('output', {recursive: true});
(async function () {
await poindexter({
docs: 'build',
output: 'public/poindexter.bundle.json', // 要放在public路径下
// title: x => 'title',
// description: x => 'desc',
keywords: ($) => {
const match = $('meta[name=keywords]').attr('content');
return match ? match.split(',') : '';
},
ignoreSelectors: ['.ignored']
});
copyFile(
'public/poindexter.bundle.json',
'build/poindexter.bundle.json',
(err) => {
if (err) throw err;
console.log(
'output/poindexter.bundle.json was copied to public/poindexter.bundle.json'
);
}
);
})();