Support settings layout as a list

pull/1548/head
shamoon 2 years ago
parent 7dfa7412ef
commit febb4cc6d5

@ -65,5 +65,20 @@ export function getSettings() {
const settingsYaml = join(process.cwd(), "config", "settings.yaml"); const settingsYaml = join(process.cwd(), "config", "settings.yaml");
const rawFileContents = readFileSync(settingsYaml, "utf8"); const rawFileContents = readFileSync(settingsYaml, "utf8");
const fileContents = substituteEnvironmentVars(rawFileContents); const fileContents = substituteEnvironmentVars(rawFileContents);
return yaml.load(fileContents) ?? {}; const initialSettings = yaml.load(fileContents) ?? {};
if (initialSettings.layout) {
// support yaml list but old spec was object so convert to that
// see https://github.com/benphelps/homepage/issues/1546
if (Array.isArray(initialSettings.layout)) {
const layoutItems = initialSettings.layout
initialSettings.layout = {}
layoutItems.forEach(i => {
const name = Object.keys(i)[0]
initialSettings.layout[name] = i[name]
})
}
}
return initialSettings
} }

Loading…
Cancel
Save