aboutsummaryrefslogtreecommitdiff
path: root/make-search-index.js
diff options
context:
space:
mode:
Diffstat (limited to 'make-search-index.js')
-rw-r--r--make-search-index.js39
1 files changed, 0 insertions, 39 deletions
diff --git a/make-search-index.js b/make-search-index.js
deleted file mode 100644
index 8d9f4cb..0000000
--- a/make-search-index.js
+++ /dev/null
@@ -1,39 +0,0 @@
-
-/*
- * make-search-index.js
- *
- * This converts a "search data" file produced by the haskell site builder into
- * a lunr.js index and saves it in JSON. Metadata for rendering search output
- * (currently titles and tags) are stored separately in an extra file.
- *
- * Installing dependencies:
- * yarnpkg add lunr
- *
- * Usage:
- * site ....some args.... --search-data-output tmp/search-raw.json
- * node make-search-index.js tmp/search-raw.json _site/search-index.json _site/search-metadata.json
- */
-
-lunr = require("lunr")
-fs = require("fs")
-
-if(process.argv.length !== 5) {
- console.error('Needs exactly 3 arguments (input json, output index).');
- process.exit(1);
-}
-
-documents = JSON.parse(fs.readFileSync(process.argv[2], {encoding: 'utf8'}))
-
-var idx = lunr(function () {
- this.ref('link')
- this.field('title', {boost: 10})
- this.field('text')
- documents.forEach(function (doc) {
- this.add(doc)
- }, this)
-})
-
-fs.writeFileSync(process.argv[3], JSON.stringify(idx), {encoding: 'utf8'})
-fs.writeFileSync(process.argv[4], JSON.stringify(
- Object.fromEntries(documents.map(x => [x.link, {"title": x.title, "tags": x.tags}]))
- ), {encoding: 'utf8'})