0bd30c5e17
Add layout system (sidebar, header, main layout), dark/light/system theme with HSL customization, 3 ambient backgrounds (mesh gradient, particle field, aurora), Cmd/Ctrl+K search dialog, page transitions, card hover effects, status pulse animations, skeleton loaders, and responsive design. Polish all existing pages with consistent theming.
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import type { LayoutServerLoad } from './$types.js';
|
|
import { prisma } from '$lib/server/prisma.js';
|
|
|
|
export const load: LayoutServerLoad = async ({ locals }) => {
|
|
// Fetch sidebar boards for the layout
|
|
let boards: Array<{ id: string; name: string; icon: string | null }> = [];
|
|
|
|
try {
|
|
if (locals.user) {
|
|
// Authenticated user: fetch boards they can access
|
|
if (locals.user.role === 'admin') {
|
|
boards = await prisma.board.findMany({
|
|
select: { id: true, name: true, icon: true },
|
|
orderBy: [{ isDefault: 'desc' }, { name: 'asc' }]
|
|
});
|
|
} else {
|
|
// Regular users: fetch all boards (permission filtering done at page level)
|
|
boards = await prisma.board.findMany({
|
|
select: { id: true, name: true, icon: true },
|
|
orderBy: [{ isDefault: 'desc' }, { name: 'asc' }]
|
|
});
|
|
}
|
|
} else {
|
|
// Guest: only guest-accessible boards
|
|
boards = await prisma.board.findMany({
|
|
where: { isGuestAccessible: true },
|
|
select: { id: true, name: true, icon: true },
|
|
orderBy: [{ isDefault: 'desc' }, { name: 'asc' }]
|
|
});
|
|
}
|
|
} catch {
|
|
// Fail gracefully — sidebar will just be empty
|
|
boards = [];
|
|
}
|
|
|
|
return {
|
|
user: locals.user,
|
|
sidebarBoards: boards
|
|
};
|
|
};
|