1
0
Fork 0

Write the updated data back to calendars.json

This commit is contained in:
Ryan Mwangi 2024-10-14 15:54:41 +03:00
parent 03493e34f1
commit c80064f135
1 changed files with 13 additions and 4 deletions

View File

@ -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!' });
});