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:
@@ -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');
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user