diff --git a/server.js b/server.js index cae56e1..ed6d94f 100644 --- a/server.js +++ b/server.js @@ -139,10 +139,19 @@ function addLinkToGroup(linkGroup, url, prefix, overrideSummary) { // Add the new link to the calendarData object let linkGroup = calendarData.linkGroups.find((group) => group.name === linkGroupName); if (!linkGroup) { - linkGroup = addLinkGroup(linkGroupName); - } - addLinkToGroup(linkGroup, linkUrl, prefix, overrideSummary); - + linkGroup = { + name: linkGroupName, + links: [] + }; + calendarsData.linkGroups.push(linkGroup); + } + linkGroup.links.push({ + url: linkUrl, + prefix, + overrideSummary + }); + // Write the updated data back to calendars.json + fs.writeFileSync(calendarsFile, JSON.stringify(calendarsData, null, 2)); res.json({ message: 'Link added successfully!' }); });