añadida pagina de posts

This commit is contained in:
2026-01-05 16:48:42 -03:00
parent 40a8c07b0d
commit f57c780910
6 changed files with 176 additions and 8 deletions
+18
View File
@@ -0,0 +1,18 @@
import { obtenerPostPorId } from '@/hooks/obtenerPostPorId.js';
import { obtenerRespuestasPorId } from '@/hooks/obtenerRespuestasPorId';
import { error } from '@sveltejs/kit';
export async function load({ params, fetch, depends }) {
let ret = await obtenerPostPorId(params.idpost, fetch, depends);
if (ret == null) return error(404, 'no existe un post con ese id.');
if (typeof ret == 'string') return error(500, ret);
let respuestas = await obtenerRespuestasPorId(params.idpost, fetch, depends);
if (respuestas == null) return error(404, 'no existe un post con ese id.');
if (typeof respuestas == 'string') return error(500, respuestas);
return {
post: ret,
respuestas: respuestas
};
}