forked from projects/fipamo
when title changes when editing a page, remove old html and markdown pages
This commit is contained in:
parent
27338da86c
commit
df9ebc7706
4 changed files with 27 additions and 4 deletions
|
@ -67,6 +67,25 @@ router.post('/write/:task?', feature_upload, (req, res) => {
|
|||
}
|
||||
body.feature = feature;
|
||||
body.deleted = false;
|
||||
//if title changes, get rid of a pages with old title
|
||||
if (body.current_title !== body.slug) {
|
||||
let path =
|
||||
moment(body.created).format('YYYY') + '/' + moment(body.created).format('MM');
|
||||
|
||||
//remove html page
|
||||
fs.unlink('public/' + path + '/' + body.current_title + '.html')
|
||||
.then()
|
||||
.catch(() => {
|
||||
//console.log('HTML ERROR', err);
|
||||
});
|
||||
|
||||
//remove markdown
|
||||
fs.unlink('content/pages/' + path + '/' + body.current_title + '.md')
|
||||
.then()
|
||||
.catch(() => {
|
||||
//console.log('MD ERROR', err);
|
||||
});
|
||||
}
|
||||
book.editPage(body, body.page_uuid, task, req.session.user)
|
||||
.then(result => {
|
||||
if (result.type === DataEvent.PAGE_ADDED) {
|
||||
|
|
|
@ -123,7 +123,6 @@ export default class Render {
|
|||
};
|
||||
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(
|
||||
|
@ -134,8 +133,8 @@ export default class Render {
|
|||
'.html'
|
||||
)
|
||||
.then()
|
||||
.catch(err => {
|
||||
console.log('ERROR', err);
|
||||
.catch(() => {
|
||||
//console.log('ERROR', err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -160,6 +159,7 @@ export default class Render {
|
|||
for (let i = 0; i < pages.length; i++) {
|
||||
let page = pages[i];
|
||||
|
||||
//TODO: filter for deleted and unpublished pages
|
||||
if (_.includes(page.metadata.tags, tag.tag_name)) {
|
||||
pageList.push({
|
||||
title: page.metadata.title,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
extends frame
|
||||
block main-content
|
||||
#post-edit-index(data-index=id data-uuid=uuid data-layout=layout)
|
||||
#post-edit-index(data-index=id data-uuid=uuid data-layout=layout data-slug=page.slug)
|
||||
#post-edit-index-wrapper
|
||||
//h2 EDIT
|
||||
=post_title
|
||||
|
|
|
@ -27,6 +27,10 @@ export default class PostActions {
|
|||
'layout',
|
||||
document.getElementById('post-edit-index').getAttribute('data-layout')
|
||||
);
|
||||
pageInfo.append(
|
||||
'current_title',
|
||||
document.getElementById('post-edit-index').getAttribute('data-slug')
|
||||
);
|
||||
pageInfo.append('content', html);
|
||||
pageInfo.append('title', document.getElementById('post_title').value);
|
||||
pageInfo.append(
|
||||
|
|
Loading…
Reference in a new issue