| // Copyright (c) 2019 Baldur Karlsson |
| // SPDX-License-Identifier: Apache-2.0 |
| var lunr = require('lunr'), |
| stdin.setEncoding('utf8') |
| stdin.on('data', function (data) { |
| stdin.on('end', function () { |
| var documents = JSON.parse(buffer.join('')) |
| var idx = lunr(function () { |
| documents.forEach(function (doc) { |
| stdout.write("var searchindex = " + JSON.stringify(idx) + ";\n") |
| for(var i=0; i < documents.length; i++) { |
| searchlookup[documents[i].id] = documents[i].title; |
| stdout.write("var searchlookup = " + JSON.stringify(searchlookup) + ";\n") |