larpaso-website/admin/lib/content-store.js
Pascal Scholz 93178a24e3 Add login-protected admin editor for content and design
Adds a self-service editor at admin.larpaso.de so texts, images, links,
Impressum/Datenschutz, fonts, font sizes and colors can be changed without
a developer. All homepage/legal content moves into content/site.json and
a new content/theme.json drives every CSS color/font/size token; the
Astro pages read from these at build time.

The admin/ service (Node/Express) provides bcrypt+session login with
rate limiting, a schema-driven form UI (including a hex/RGB/alpha color
picker), image upload, and a publish action that runs the Astro build
and republishes into a volume shared with the nginx website container -
so edits go live without redeploying that container.

See DEPLOYMENT_ADMIN.md for the server-side setup steps.
2026-09-21 21:35:09 +02:00

26 lines
873 B
JavaScript

const fs = require('fs');
const path = require('path');
const PROJECT_DIR = process.env.PROJECT_DIR || path.resolve(__dirname, '..', '..');
const CONTENT_PATH = process.env.CONTENT_PATH || path.join(PROJECT_DIR, 'content', 'site.json');
const THEME_PATH = process.env.THEME_PATH || path.join(PROJECT_DIR, 'content', 'theme.json');
function readJson(filePath) {
return JSON.parse(fs.readFileSync(filePath, 'utf8'));
}
function writeJson(filePath, data) {
const tmpPath = `${filePath}.tmp`;
fs.writeFileSync(tmpPath, JSON.stringify(data, null, 2) + '\n', 'utf8');
fs.renameSync(tmpPath, filePath);
}
module.exports = {
readContent: () => readJson(CONTENT_PATH),
writeContent: (data) => writeJson(CONTENT_PATH, data),
readTheme: () => readJson(THEME_PATH),
writeTheme: (data) => writeJson(THEME_PATH, data),
CONTENT_PATH,
THEME_PATH,
PROJECT_DIR,
};