Fix general category handling

This commit is contained in:
Sean Morley
2024-11-26 17:39:10 -05:00
parent ce0b82acb7
commit adf45ff557
16 changed files with 192 additions and 126 deletions

View File

@@ -1,7 +1,6 @@
const PUBLIC_SERVER_URL = process.env['PUBLIC_SERVER_URL'];
import { redirect, type Actions } from '@sveltejs/kit';
import type { PageServerLoad } from './$types';
import { getRandomBackground } from '$lib';
import { themes } from '$lib';
const serverEndpoint = PUBLIC_SERVER_URL || 'http://localhost:8000';
@@ -9,21 +8,7 @@ export const actions: Actions = {
setTheme: async ({ url, cookies }) => {
const theme = url.searchParams.get('theme');
// change the theme only if it is one of the allowed themes
if (
theme &&
[
'light',
'dark',
'night',
'retro',
'forest',
'aqua',
'forest',
'aestheticLight',
'aestheticDark',
'emerald'
].includes(theme)
) {
if (theme && themes.find((t) => t.name === theme)) {
cookies.set('colortheme', theme, {
path: '/',
maxAge: 60 * 60 * 24 * 365