aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/constants.mjs2
-rw-r--r--app/directory.mjs14
2 files changed, 12 insertions, 4 deletions
diff --git a/app/constants.mjs b/app/constants.mjs
index 96068e1..e9b4730 100644
--- a/app/constants.mjs
+++ b/app/constants.mjs
@@ -2,7 +2,7 @@
export const SERVER_PORT = 3000;
export const PARSER_MAX_RECURSION = 20;
-export const PURGE_COOLDOWN_MIN = 10;
+export const PURGE_COOLDOWN_MIN = -1;
export const PAGES_DIR = 'pages';
export const TEMPLATE_DIR = 'pages/tempates';
export const IMAGES_DIR = 'pages/images';
diff --git a/app/directory.mjs b/app/directory.mjs
index 1fddf23..89a6ee9 100644
--- a/app/directory.mjs
+++ b/app/directory.mjs
@@ -23,7 +23,12 @@ export function pageFor(path) {
}
export function buildPage(path) {
- let data = readFileSync(`${PAGES_DIR}/${path}.wiki`, 'utf-8');
+ let data;
+ try {
+ data = readFileSync(`${PAGES_DIR}/${path}.wiki`, 'utf-8');
+ } catch {
+ return false;
+ }
let result = parse(data);
let title = result.metadata.displayTitle ?? 'Unnamed page';
let content = `<h1>${title}</h1>${result.html}`;
@@ -35,6 +40,7 @@ export function buildPage(path) {
displayTitle: title
};
pages[path] = page;
+ return true;
}
export function rebuild() {
@@ -67,8 +73,10 @@ export function purge(path) {
return false;
} else {
pages[path] = {};
- buildPage(path);
- return true;
+ if (buildPage(path)) {
+ return true;
+ }
+ delete pages[path];
}
}
return false;