feat: paste creation; paste viewing; more langs supported; jwt settings class; paste settings class; data validation on paste metadata modification

This commit is contained in:
2025-12-28 08:34:53 -05:00
parent adad139081
commit b9b14a3d5a
21 changed files with 1203 additions and 77 deletions
@@ -0,0 +1,30 @@
import type { PageServerLoad } from './$types';
import { getShiki } from '$lib/shiki';
export const load: PageServerLoad = async ({ params, fetch }) => {
const { id } = params;
const paste = await fetch(`/api/paste/${id}`);
if (paste.status === 404) {
return {
status: 404,
error: { message: 'Paste not found' }
};
}
const pasteData = await paste.json();
const pasteContent = await fetch(`/api/paste/raw/${id}`);
const pasteOptions = await fetch('/api/paste/create/options');
const options = await pasteOptions.json();
const content = await pasteContent.text();
let highlighted = '';
if (pasteData && content) {
const shiki = await getShiki();
highlighted = shiki.codeToHtml(content, {
lang: pasteData.syntax || 'plaintext',
theme: 'github-dark'
});
}
return { paste: pasteData, content, options, highlighted };
};