summaryrefslogtreecommitdiffstats
path: root/docs/indexer.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-03 07:47:33 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-03 07:47:33 +0000
commit39bf3544d4064a528a85c21a9069a9cae364a6c1 (patch)
treeaa318bfe1e7816ba9492aff0cdd2454d278f5836 /docs/indexer.js
parentAdding upstream version 0.45+dfsg. (diff)
downloadjinjax-39bf3544d4064a528a85c21a9069a9cae364a6c1.tar.xz
jinjax-39bf3544d4064a528a85c21a9069a9cae364a6c1.zip
Adding upstream version 0.46.upstream/0.46
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--docs/indexer.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/docs/indexer.js b/docs/indexer.js
new file mode 100644
index 0000000..637645b
--- /dev/null
+++ b/docs/indexer.js
@@ -0,0 +1,27 @@
+var lunr = require("lunr");
+require("lunr-languages/lunr.stemmer.support")(lunr);
+const fs = require("node:fs");
+
+function build_index([lang, outpath]) {
+ lang = lang || "en"
+ outpath = outpath || "."
+
+ if (lang !== "en") {
+ const lunr_lang = require(`lunr-languages/lunr.${lang}`)(lunr);
+ this.use(lunr_lang);
+ }
+
+ const idx = lunr(function() {
+ this.ref("id");
+ this.field("title", { boost: 10 });
+ this.field("body");
+ const docs = JSON.parse(fs.readFileSync(`${outpath}/docs-${lang}.json`));
+
+ for (let doc in docs) {
+ this.add(doc)
+ }
+ })
+ fs.writeFileSync(`${outpath}/search-${lang}.json`, JSON.stringify(idx));
+}
+
+build_index(process.argv.slice(2));