From 80d8ff99ea82907b1efff2a955d308b38ef7d358 Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Mon, 26 Nov 2018 23:19:52 -0800 Subject: [PATCH] Add a script to create an index for Algolia --- package.json | 3 ++- scripts/createSearchIndex.js | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 scripts/createSearchIndex.js diff --git a/package.json b/package.json index d06e8828..e3d3af41 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,8 @@ "build": "react-scripts build", "test": "react-scripts test --env=jsdom", "eject": "react-scripts eject", - "build-index": "node ./scripts/findSkins.js" + "build-index": "node ./scripts/findSkins.js", + "create-search-index": "node ./scripts/createSearchIndex.js > index.json" }, "prettier": {}, "browserslist": [ diff --git a/scripts/createSearchIndex.js b/scripts/createSearchIndex.js new file mode 100644 index 00000000..918aace5 --- /dev/null +++ b/scripts/createSearchIndex.js @@ -0,0 +1,9 @@ +const skins = require("../src/skins.json"); + +const indexes = []; + +Object.entries(skins).forEach(([hash, { fileName }]) => { + indexes.push({ objectID: hash, fileName }); +}); + +console.log(JSON.stringify(indexes, null, 2));