From 1b79f8bb7fa8a4d72a1f60e11a3aa8bc81b6e3a8 Mon Sep 17 00:00:00 2001 From: Alexander Lee Date: Wed, 15 Sep 2021 17:00:10 +0800 Subject: [PATCH] Feat: add ability to edit description in settings (#280) --- classes/Settings.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/classes/Settings.js b/classes/Settings.js index fb6de8367..bee68f202 100644 --- a/classes/Settings.js +++ b/classes/Settings.js @@ -99,6 +99,7 @@ class Settings { const configFieldsRequired = { url: configContent.url, title: configContent.title, + description: configContent.description, favicon: configContent.favicon, shareicon: configContent.shareicon, is_government: configContent.is_government, @@ -211,11 +212,16 @@ class Settings { const newConfigContent = Base64.encode(yaml.stringify(configSettingsObj)) await configResp.update(newConfigContent, config.sha) - // Update title in homepage as well if it's changed - if (configContent.title !== configSettingsObj.title) { + // Update title and description in homepage as well if it's changed + const hasTitleChanged = configContent.title !== configSettingsObj.title + const hasDescriptionChanged = + configContent.description !== configSettingsObj.description + if (hasTitleChanged || hasDescriptionChanged) { const { content: homepageContentObj, sha } = homepage - homepageContentObj.title = configSettings.title + if (hasTitleChanged) homepageContentObj.title = configSettings.title + if (hasDescriptionChanged) + homepageContentObj.description = configSettings.description const homepageFrontMatter = yaml.stringify(homepageContentObj) const homepageContent = ["---\n", homepageFrontMatter, "---"].join("")