Clean up changes

Seperated all routes into seperate files for neatness, and I've made the comments.json store only the comments, comments_counter is in the new data.json file which also stores the hitcount.

Signed-off-by: max <deadvey@localhost.localdomain>
This commit is contained in:
max
2025-09-24 10:02:28 +01:00
parent 0541b704db
commit 93c5f13750
11 changed files with 464 additions and 400 deletions

View File

@@ -1,6 +1,7 @@
import { createRequire } from 'module';
const require = createRequire(import.meta.url)
const config = require("../config.json")
const fs = require('fs')
const locale = require(`../locales/${config.locale}.json`)
// The configuration defines a date format using the date-fns (a datetime library) syntax
@@ -116,3 +117,13 @@ export function render_md(content) {
})
return md.render(content)
};
// Literally just +1 to the hitcount
export function increment_hitcount() {
if (config.data_storage == 'json') {
let other_data = require('../data/data.json');
other_data.hitcount += 1
console.log(`/ Is loaded, hitcount: ${other_data.hitcount}`)
fs.writeFileSync(`../data/data.json`, `${JSON.stringify(other_data)}`, 'utf-8');
}
};