From 02d3b039cb90cd44252929c5837a8692dd040e60 Mon Sep 17 00:00:00 2001 From: Alexander Lee Date: Mon, 20 Sep 2021 17:16:00 +0800 Subject: [PATCH] hotfix: properly handle subcollection file update --- newroutes/collectionPages.js | 38 +++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/newroutes/collectionPages.js b/newroutes/collectionPages.js index ebb4a932a..26d9514ed 100644 --- a/newroutes/collectionPages.js +++ b/newroutes/collectionPages.js @@ -115,26 +115,28 @@ class CollectionPagesRouter { sha, }) } - } - if (newFileName) { - updateResp = await this.collectionPageService.rename(reqDetails, { - oldFileName: pageName, - newFileName, - collectionName, - content: pageBody, - frontMatter, - sha, - }) } else { - updateResp = await this.collectionPageService.update(reqDetails, { - fileName: pageName, - collectionName, - content: pageBody, - frontMatter, - sha, - }) + /* eslint-disable no-lonely-if */ + if (newFileName) { + updateResp = await this.collectionPageService.rename(reqDetails, { + oldFileName: pageName, + newFileName, + collectionName, + content: pageBody, + frontMatter, + sha, + }) + } else { + updateResp = await this.collectionPageService.update(reqDetails, { + fileName: pageName, + collectionName, + content: pageBody, + frontMatter, + sha, + }) + } } - + /* eslint-enable no-lonely-if */ return res.status(200).json(updateResp) }