diff --git a/api/search.js b/api/search.js index f963b1ff7c07bf1efdd37af432dccf86968aed89..a1affc321a7993a4b56d52851569ac51e84c3788 100644 --- a/api/search.js +++ b/api/search.js @@ -3,13 +3,13 @@ const path = require('path'); const searchIndex = require('../scripts/searchIndex'); const parseMarkdown = require('../scripts/parseMarkdown'); -const indexPath = path.resolve(__dirname, './index.json'); -const index = JSON.parse(fs.readFileSync(indexPath, 'utf-8')); +// const indexPath = path.resolve(__dirname, './index.json'); +// const index = JSON.parse(fs.readFileSync(indexPath, 'utf-8')); module.exports = async (req, res) => { - const files = fs.readdirSync(__dirname); + const files = fs.readdirSync(path.resolve(__dirname, '../build')); // const parentDirFiles = fs.readdirSync('..'); - res.json({ files, parentDirFiles }); + res.json({ files }); return; diff --git a/config.js b/config.js index e140436517570ef306ac8f7363d8808da2b18122..bcf8046c13a52307249be81bd9e8b46afcb19394 100644 --- a/config.js +++ b/config.js @@ -1,6 +1,6 @@ const path = require('path'); module.exports = { - indexOutputPath: path.resolve(__dirname, 'api'), + indexOutputPath: path.resolve(__dirname, 'build/indices'), indexName: 'index.json' } diff --git a/now.json b/now.json new file mode 100644 index 0000000000000000000000000000000000000000..1dbdcb8f853baa8340ace5681ccb27ef99fbd463 --- /dev/null +++ b/now.json @@ -0,0 +1,7 @@ +{ + "functions": { + "api/search.js": { + "includeFiles": "build/indices/**" + } + } +} diff --git a/package.json b/package.json index ce6fa87d18a0e3799a18bad27ea1be74504d287d..898ba94551ee135fa5566af7c88079e8c8643052 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "description": "", "main": "index.js", "scripts": { + "prebuild": "rm -rf build && mkdir -p build/indices", "build": "node scripts/generateIndex.js" }, "keywords": [],