From 5a9a14deaad96317a3c0fe04cd7d27baa56adecc Mon Sep 17 00:00:00 2001 From: Ro Date: Wed, 24 Jun 2020 13:23:53 -0700 Subject: [PATCH] pages marked unpublished are not rendered. changing publish status to false removes rendered html page --- brain/data/Render.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/brain/data/Render.js b/brain/data/Render.js index e37f48b..5947115 100644 --- a/brain/data/Render.js +++ b/brain/data/Render.js @@ -31,12 +31,12 @@ export default class Render { .then(config => { let response = []; let count = _.filter(pages, page => { - return page.metadata.deleted === false; + return page.metadata.deleted === false && page.metadata.published === true; }).length; let rendered = 0; for (let index = 0; index < pages.length; index++) { const page = pages[index]; - if (page.metadata.deleted === false) { + if (page.metadata.deleted === false && page.metadata.published === true) { let writeFile, template; //create case for index path let path = @@ -103,8 +103,27 @@ export default class Render { resolve(response); } } else { + if (count === 0) { + response = { + type: DataEvent.PAGES_RENDERED, + message: 'No page rendering needed' + }; + resolve(response); + } //don't render delete pages //check to see if deleted pages have been renderered and delete them + if (page.metadata.layout !== 'index') { + fs.unlink( + 'public/' + + page.metadata.path + + '/' + + page.metadata.slug + + '.html' + ).then(() => { + console.log('REMOVED'); + }); + } + console.log('REMOVE', page.metadata.slug); } } })