mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-08 14:38:47 +00:00
fix case with empty bookmarks and widgets
This commit is contained in:
parent
756f6310af
commit
dadd501843
1 changed files with 4 additions and 0 deletions
|
@ -14,6 +14,8 @@ export async function bookmarksResponse() {
|
||||||
const fileContents = await fs.readFile(bookmarksYaml, "utf8");
|
const fileContents = await fs.readFile(bookmarksYaml, "utf8");
|
||||||
const bookmarks = yaml.load(fileContents);
|
const bookmarks = yaml.load(fileContents);
|
||||||
|
|
||||||
|
if (!bookmarks) return [];
|
||||||
|
|
||||||
// map easy to write YAML objects into easy to consume JS arrays
|
// map easy to write YAML objects into easy to consume JS arrays
|
||||||
const bookmarksArray = bookmarks.map((group) => ({
|
const bookmarksArray = bookmarks.map((group) => ({
|
||||||
name: Object.keys(group)[0],
|
name: Object.keys(group)[0],
|
||||||
|
@ -33,6 +35,8 @@ export async function widgetsResponse() {
|
||||||
const fileContents = await fs.readFile(widgetsYaml, "utf8");
|
const fileContents = await fs.readFile(widgetsYaml, "utf8");
|
||||||
const widgets = yaml.load(fileContents);
|
const widgets = yaml.load(fileContents);
|
||||||
|
|
||||||
|
if (!widgets) return [];
|
||||||
|
|
||||||
// map easy to write YAML objects into easy to consume JS arrays
|
// map easy to write YAML objects into easy to consume JS arrays
|
||||||
const widgetsArray = widgets.map((group) => ({
|
const widgetsArray = widgets.map((group) => ({
|
||||||
type: Object.keys(group)[0],
|
type: Object.keys(group)[0],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue