Load background from server page

This commit is contained in:
Sean Morley
2024-10-20 21:56:16 -04:00
parent c084f348d9
commit f34d533dc6
5 changed files with 96 additions and 26 deletions

View File

@@ -1,11 +1,22 @@
import { fail, redirect } from '@sveltejs/kit';
import type { Actions, PageServerLoad } from './$types';
import { getRandomBackground, getRandomQuote } from '$lib';
const PUBLIC_SERVER_URL = process.env['PUBLIC_SERVER_URL'];
export const load: PageServerLoad = async (event) => {
if (event.locals.user) {
return redirect(302, '/');
} else {
const quote = getRandomQuote();
const background = getRandomBackground();
return {
props: {
quote,
background
}
};
}
};