|
|
@ -75,10 +75,11 @@ module.exports = {
|
|
|
|
const contentPath = pageHelper.getPagePath(relPath)
|
|
|
|
const contentPath = pageHelper.getPagePath(relPath)
|
|
|
|
const itemContents = await fs.readFile(path.join(fullPath, relPath), 'utf8')
|
|
|
|
const itemContents = await fs.readFile(path.join(fullPath, relPath), 'utf8')
|
|
|
|
const pageData = WIKI.models.pages.parseMetadata(itemContents, contentType)
|
|
|
|
const pageData = WIKI.models.pages.parseMetadata(itemContents, contentType)
|
|
|
|
const currentPage = await WIKI.models.pages.query().findOne({
|
|
|
|
const currentPage = await WIKI.models.pages.getPageFromDb({
|
|
|
|
path: contentPath.path,
|
|
|
|
path: contentPath.path,
|
|
|
|
localeCode: contentPath.locale
|
|
|
|
locale: contentPath.locale
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
const newTags = !_.isNil(pageData.tags) ? _.get(pageData, 'tags', '').split(', ') : false
|
|
|
|
if (currentPage) {
|
|
|
|
if (currentPage) {
|
|
|
|
// Already in the DB, can mark as modified
|
|
|
|
// Already in the DB, can mark as modified
|
|
|
|
WIKI.logger.info(`(STORAGE/${moduleName}) Page marked as modified: ${relPath}`)
|
|
|
|
WIKI.logger.info(`(STORAGE/${moduleName}) Page marked as modified: ${relPath}`)
|
|
|
@ -86,6 +87,7 @@ module.exports = {
|
|
|
|
id: currentPage.id,
|
|
|
|
id: currentPage.id,
|
|
|
|
title: _.get(pageData, 'title', currentPage.title),
|
|
|
|
title: _.get(pageData, 'title', currentPage.title),
|
|
|
|
description: _.get(pageData, 'description', currentPage.description) || '',
|
|
|
|
description: _.get(pageData, 'description', currentPage.description) || '',
|
|
|
|
|
|
|
|
tags: newTags || currentPage.tags.map(t => t.tag),
|
|
|
|
isPublished: _.get(pageData, 'isPublished', currentPage.isPublished),
|
|
|
|
isPublished: _.get(pageData, 'isPublished', currentPage.isPublished),
|
|
|
|
isPrivate: false,
|
|
|
|
isPrivate: false,
|
|
|
|
content: pageData.content,
|
|
|
|
content: pageData.content,
|
|
|
@ -101,6 +103,7 @@ module.exports = {
|
|
|
|
locale: contentPath.locale,
|
|
|
|
locale: contentPath.locale,
|
|
|
|
title: _.get(pageData, 'title', _.last(contentPath.path.split('/'))),
|
|
|
|
title: _.get(pageData, 'title', _.last(contentPath.path.split('/'))),
|
|
|
|
description: _.get(pageData, 'description', '') || '',
|
|
|
|
description: _.get(pageData, 'description', '') || '',
|
|
|
|
|
|
|
|
tags: newTags || [],
|
|
|
|
isPublished: _.get(pageData, 'isPublished', true),
|
|
|
|
isPublished: _.get(pageData, 'isPublished', true),
|
|
|
|
isPrivate: false,
|
|
|
|
isPrivate: false,
|
|
|
|
content: pageData.content,
|
|
|
|
content: pageData.content,
|
|
|
|