Bugfixing and include page selector

This commit is contained in:
2022-10-08 13:28:16 +02:00
parent 84057788b3
commit 7bb69e9b37
4 changed files with 54 additions and 47 deletions

View File

@ -13,13 +13,24 @@ const projectServerErrorHtml = `<div class="${"error"}">Sorry! A server error ha
const ad = asciidoctor();
// No error catching here as we are screwed if this fails
const listPath = resolve("./public", "content", "list.json");
const projectPath = resolve("./public", "content", "projects");
const diaryPath = resolve("./public", "content", "diaries");
// No error catching here as we are screwed if this fails
const projectFiles = readdirSync(projectPath, { withFileTypes: true }).filter((f) => f.isFile() && f.name.endsWith(".adoc"));
// As we need the diaries too, no filter here
const diaryFiles = readdirSync(diaryPath, { withFileTypes: true });
export async function getContentList() {
try {
const list = await readFile(listPath, { encoding: "utf-8" });
return JSON.parse(list);
} catch (e) {
console.error(e);
return [];
}
}
export async function generateContent(content: Project|Diary, selectedPage?: number): Promise<string> {
if(!content) return projectEmpty;
switch (content.type) {