From 532f58880259f88847b2a621fa95259150bb7c4b Mon Sep 17 00:00:00 2001 From: Script Raccoon Date: Thu, 2 Jul 2026 16:24:13 +0200 Subject: [PATCH 1/3] show functors on category detail page --- src/lib/server/fetchers/category.ts | 45 ++++++++++++++++----------- src/pages/StructureDetailPage.svelte | 4 +++ src/routes/category/[id]/+page.svelte | 19 +++++++++++ 3 files changed, 50 insertions(+), 18 deletions(-) diff --git a/src/lib/server/fetchers/category.ts b/src/lib/server/fetchers/category.ts index aa6a2583..4ae32a78 100644 --- a/src/lib/server/fetchers/category.ts +++ b/src/lib/server/fetchers/category.ts @@ -10,35 +10,43 @@ import { error } from '@sveltejs/kit' export function fetch_category(id: string) { const { results, err } = batch< - [CategorySpecificDisplay, SpecialObject, SpecialMorphism] + [CategorySpecificDisplay, SpecialObject, SpecialMorphism, StructureShort] >([ // specific information for the category sql` - SELECT c.objects, c.morphisms - FROM categories c - WHERE c.id = ${id} - `, + SELECT c.objects, c.morphisms + FROM categories c + WHERE c.id = ${id} + `, // special objects sql` - SELECT s.type, s.description - FROM special_objects s - INNER JOIN special_object_types t ON t.type = s.type - WHERE s.category_id = ${id} - ORDER BY t.id - `, + SELECT s.type, s.description + FROM special_objects s + INNER JOIN special_object_types t ON t.type = s.type + WHERE s.category_id = ${id} + ORDER BY t.id + `, // special morphisms sql` - SELECT t.type, s.description, s.proof - FROM special_morphism_types t - LEFT JOIN special_morphisms s - ON s.type = t.type AND s.category_id = ${id} - ORDER BY t.id - `, + SELECT t.type, s.description, s.proof + FROM special_morphism_types t + LEFT JOIN special_morphisms s + ON s.type = t.type AND s.category_id = ${id} + ORDER BY t.id + `, + // functors whose source or target is the current category + sql` + SELECT f.id, s.name + FROM functors f + INNER JOIN structures s ON s.id = f.id + WHERE f.source = ${id} OR f.target = ${id} + ORDER BY lower(s.name) + `, ]) if (err) error(500, 'Could not load category') - const [categories, special_objects, special_morphisms] = results + const [categories, special_objects, special_morphisms, functors] = results if (!categories.length) error(404, `Could not find category with ID '${id}'`) @@ -46,6 +54,7 @@ export function fetch_category(id: string) { ...categories[0], special_objects, special_morphisms, + functors, } } diff --git a/src/pages/StructureDetailPage.svelte b/src/pages/StructureDetailPage.svelte index 0baaa5c7..71fbbf65 100644 --- a/src/pages/StructureDetailPage.svelte +++ b/src/pages/StructureDetailPage.svelte @@ -30,6 +30,7 @@ comments: CommentObject[] definition?: Snippet specials?: Snippet + footer?: Snippet } let { @@ -45,6 +46,7 @@ comments, definition, specials, + footer, }: Props = $props() @@ -118,6 +120,8 @@ +{@render footer?.()} +