renaming pages also a thing

This commit is contained in:
2024-12-17 14:49:34 -07:00
parent b020673282
commit 0f1d999e16
7 changed files with 127 additions and 42 deletions

View File

@@ -65,7 +65,7 @@ const getItem = async <T extends CourseItemType>(
) as CourseItemReturnType<T>;
} else if (type === "Page") {
return localPageMarkdownUtils.parseMarkdown(
rawFile
rawFile, name
) as CourseItemReturnType<T>;
}

View File

@@ -37,25 +37,12 @@ export const pageFileStorageService = {
courseName,
moduleName,
"pages",
page.name + ".md"
pageName + ".md"
);
const pageMarkdown = localPageMarkdownUtils.toMarkdown(page);
console.log(`Saving page ${filePath}`);
await fs.writeFile(filePath, pageMarkdown);
const pageNameIsChanged = pageName !== page.name;
if (pageNameIsChanged) {
console.log("removing old page after name change " + pageName);
const oldFilePath = path.join(
basePath,
courseName,
moduleName,
"pages",
pageName + ".md"
);
await fs.unlink(oldFilePath);
}
},
async delete({
courseName,