Skip to content

Commit d748401

Browse files
committed
update generate lunr index
1 parent ae680c8 commit d748401

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

.github/workflows/checklink.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
run: hugo --environment GitHubPages -d $GITHUB_WORKSPACE/dist --buildFuture
4040
- name: Generate Search index
4141
run: |
42-
node ./assets/js/generate-lunr-index.js
42+
node ./assets/js/generate-lunr-index.js $GITHUB_WORKSPACE/dist
4343
- name: Test HTML
4444
uses: wjdp/htmltest-action@master
4545
with:

assets/js/generate-lunr-index.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
const fs = require('fs');
22
const lunr = require('lunr');
33

4-
const data = JSON.parse(fs.readFileSync('./docs/offline-search-index.json'));
4+
const args = process.argv.slice(2);
5+
const destination = args[0] ?? ".";
6+
7+
const data = JSON.parse(fs.readFileSync(`${destination}/docs/offline-search-index.json`));
58

69
const idx = lunr(function () {
710
this.ref('ref');
@@ -21,4 +24,10 @@ const idx = lunr(function () {
2124
});
2225
});
2326

24-
fs.writeFileSync('./assets/json/lunr-index.json', JSON.stringify(idx));
27+
fs.writeFileSync(`${destination}/assets/json/lunr-index.json`, JSON.stringify(idx));
28+
29+
// check if file got created
30+
if (!fs.existsSync(`${destination}/assets/json/lunr-index.json`)) {
31+
console.error('Failed to create lunr index');
32+
process.exit(1);
33+
}

0 commit comments

Comments
 (0)