feat: mocked up search form on site

This commit is contained in:
2018-08-30 20:34:32 -07:00
parent 699a03c7c0
commit 22a95c3fe8
3 changed files with 126 additions and 18 deletions

View File

@@ -2,15 +2,24 @@ import http from 'http';
import fs from 'fs';
import ejs from 'ejs';
const srcFile = 'src/index.html';
const srcFile = 'src/index.ejs';
const destFile = 'dist/index.html';
function build() {
const data = {};
function getData() {
return new Promise((resolve, reject) => {
fs.readFile('../scraper/db.json', (err, str) => {
if (err) reject(err);
else resolve(str);
});
});
}
async function build() {
const data = await getData();
const options = {};
return new Promise((resolve, reject) => {
ejs.renderFile(srcFile, data, options, (err, str) => {
ejs.renderFile(srcFile, { data }, options, (err, str) => {
if (err) reject(err);
else {
fs.writeFile(destFile, str, er => {