adding storage for lectures

This commit is contained in:
2024-11-01 17:10:06 -06:00
parent dcecf3172e
commit bd8c9140eb
12 changed files with 181 additions and 464 deletions

View File

@@ -0,0 +1,30 @@
import { extractLabelValue } from "@/models/local/assignment/utils/markdownUtils";
import { Lecture } from "@/models/local/lecture";
export function parseLecture(fileContent: string): Lecture {
try {
const settings = fileContent.split("---\n")[0];
const name = extractLabelValue(settings, "Name");
const date = extractLabelValue(settings, "Date");
const content = fileContent.split("---\n")[1].trim();
return {
name,
date,
content,
};
} catch (error) {
console.error("Error parsing lecture", fileContent);
throw error;
}
}
export function lectureToString(lecture: Lecture) {
return `Name: ${lecture.name}
Date: ${lecture.date}
---
${lecture.content}`;
}
export const lectureFolderName = "00 - lectures"