2012b0bab9
- Added default_language field to general settings state in SettingsPage - Replaced LanguageSelector component with simple select dropdown on settings page - Fixed public settings endpoint to read general_default_language from database - Language setting now properly saved when clicking Save Settings button - Setting is correctly used by gallery login page and legal pages 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
33 lines
905 B
JavaScript
33 lines
905 B
JavaScript
const express = require('express');
|
|
const { db } = require('../database/db');
|
|
const router = express.Router();
|
|
|
|
// Get public CMS page
|
|
router.get('/pages/:slug', async (req, res) => {
|
|
try {
|
|
const { slug } = req.params;
|
|
const { lang = 'en' } = req.query;
|
|
|
|
const page = await db('cms_pages').where('slug', slug).first();
|
|
|
|
if (!page) {
|
|
return res.status(404).json({ error: 'Page not found' });
|
|
}
|
|
|
|
// Return the appropriate language version
|
|
const title = lang === 'de' ? page.title_de : page.title_en;
|
|
const content = lang === 'de' ? page.content_de : page.content_en;
|
|
|
|
res.json({
|
|
title,
|
|
content,
|
|
slug: page.slug,
|
|
updated_at: page.updated_at
|
|
});
|
|
} catch (error) {
|
|
console.error('Error fetching public CMS page:', error);
|
|
res.status(500).json({ error: 'Failed to fetch page' });
|
|
}
|
|
});
|
|
|
|
module.exports = router; |