diff --git a/server.js b/server.js index f479b03..c06f309 100644 --- a/server.js +++ b/server.js @@ -187,7 +187,7 @@ Server.prototype.fillTemplate = function (file, templateVars = {}) { Server.prototype.generateHomePage = function (req) { const files = fs.readdirSync(this.fileLocation).filter(fileName => fileName.includes('.json')); - const books = files.map(fileName => { + let books = files.map(fileName => { const bookData = JSON.parse(fs.readFileSync(path.resolve(this.fileLocation, fileName), 'utf8')); if (bookData.hasOwnProperty('fileName')) return ''; @@ -220,6 +220,11 @@ Server.prototype.generateHomePage = function (req) { modal, }); }).join(''); + + if (books == '') { + books = '
+ Use this form to add a book to the library! +
+