diff options
| author | LMBishop <13875753+LMBishop@users.noreply.github.com> | 2021-11-22 14:17:44 +0000 |
|---|---|---|
| committer | LMBishop <13875753+LMBishop@users.noreply.github.com> | 2021-11-22 14:17:44 +0000 |
| commit | a84425a42e9246243dffd23dba33b4d4a5b626ac (patch) | |
| tree | 5e0a356407e50b172afeb8662a6a6f2fb6e334fe /app/directory.mjs | |
| parent | 7d1aa7d48e5f16d639713804d6a86290fac7ffab (diff) | |
Update styles & add page rebuilding
Diffstat (limited to 'app/directory.mjs')
| -rw-r--r-- | app/directory.mjs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/app/directory.mjs b/app/directory.mjs index 38b05ca..b470bc7 100644 --- a/app/directory.mjs +++ b/app/directory.mjs @@ -1,6 +1,6 @@ 'use strict'; -import { PAGES_DIR, PURGE_COOLDOWN_MIN } from './constants.mjs'; +import { PAGES_DIR, PURGE_COOLDOWN_MIN, REBUILD_COOLDOWN_MIN } from './constants.mjs'; import { parse } from './wikiparser.mjs'; import { readFileSync, readdirSync } from 'fs'; @@ -22,7 +22,7 @@ export function pageFor(path) { return page; } -export function buildPage(path) { +function buildPage(path) { let data; try { data = readFileSync(`${PAGES_DIR}/${path}.wiki`, 'utf-8'); @@ -47,6 +47,9 @@ export function buildPage(path) { } export function rebuild() { + if (metadata.fileTreeBuildTime + REBUILD_COOLDOWN_MIN * 60 * 1000 > Date.now()) { + return false; + } for (var page in pages) { delete pages[page]; } @@ -70,6 +73,7 @@ export function rebuild() { }); metadata.navbar = primaryPages; metadata.fileTreeBuildTime = new Date(); + return true; } export function exists(path) { |
