pages marked unpublished are not rendered. changing publish status to false removes rendered html page

This commit is contained in:
Ro 2020-06-24 13:23:53 -07:00
parent 33decbea9a
commit 5a9a14deaa

View file

@ -31,12 +31,12 @@ export default class Render {
.then(config => { .then(config => {
let response = []; let response = [];
let count = _.filter(pages, page => { let count = _.filter(pages, page => {
return page.metadata.deleted === false; return page.metadata.deleted === false && page.metadata.published === true;
}).length; }).length;
let rendered = 0; let rendered = 0;
for (let index = 0; index < pages.length; index++) { for (let index = 0; index < pages.length; index++) {
const page = pages[index]; const page = pages[index];
if (page.metadata.deleted === false) { if (page.metadata.deleted === false && page.metadata.published === true) {
let writeFile, template; let writeFile, template;
//create case for index path //create case for index path
let path = let path =
@ -103,8 +103,27 @@ export default class Render {
resolve(response); resolve(response);
} }
} else { } else {
if (count === 0) {
response = {
type: DataEvent.PAGES_RENDERED,
message: 'No page rendering needed'
};
resolve(response);
}
//don't render delete pages //don't render delete pages
//check to see if deleted pages have been renderered and delete them //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);
} }
} }
}) })