feat: add recent pastes page with data fetching and display logic

This commit is contained in:
2026-01-20 11:26:06 -05:00
parent 698183690c
commit 8a6ab29f52
3 changed files with 66 additions and 1 deletions
@@ -0,0 +1,19 @@
import type { PageServerLoad } from './$types';
import type { Paste } from '$lib/types/paste';
import { extractError } from '$lib/utils/misc';
export const load: PageServerLoad = async ({ fetch }) => {
try {
const res = await fetch('/api/paste/recent');
if (!res.ok) {
const errorMsg = extractError(await res.json()) || 'Failed to fetch recent pastes.';
throw new Error(errorMsg);
}
const recentPastes: Paste[] = await res.json();
return { recentPastes };
}
catch (error) {
console.error(error);
return { recentPastes: [] };
}
};