Skip to content

Commit

Permalink
Feat: add ability to edit description in settings (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderleegs authored Sep 15, 2021
1 parent 8862482 commit 1b79f8b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions classes/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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("")
Expand Down

0 comments on commit 1b79f8b

Please sign in to comment.