Skip to content

Commit 5dcd6ab

Browse files
committed
create list page of lemmas
1 parent 7a61eed commit 5dcd6ab

5 files changed

Lines changed: 46 additions & 8 deletions

File tree

src/lib/commons/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ export type FunctorPropertyAssignment = Replace<
157157
>
158158

159159
export type Lemma = {
160+
id: string
160161
title: string
161162
claim: string
162163
proof: string

src/routes/category-implications/+page.svelte

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@
7070
well.
7171
</p>
7272

73+
<p class="hint">
74+
In some cases, implications are a bit too rigid, which is why we also provide a small
75+
collection of <a href="/lemmas">lemmas</a>.
76+
</p>
77+
7378
<button class="button" onclick={toggle}>
7479
{#if show_deduced_implications}
7580
Hide deduced implications

src/routes/lemma/[id]/+page.server.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,13 @@ import { batch, query } from '$lib/server/db.catdat'
33
import { render_nested_formulas } from '$lib/server/rendering'
44
import { error } from '@sveltejs/kit'
55
import sql from 'sql-template-tag'
6-
import type { EntryGenerator } from './$types'
7-
8-
export const entries: EntryGenerator = async () => {
9-
const { rows, err } = query<{ id: string }>(sql`SELECT id FROM lemmas`)
10-
if (err) throw new Error('Database error: Failed to load tags')
11-
return rows
12-
}
136

147
export const load = async (event) => {
158
const id = event.params.id
169

1710
const { results, err } = batch<[Lemma, CategoryShort, { id: string }]>([
1811
sql`
19-
SELECT title, claim, proof FROM lemmas WHERE id = ${id}
12+
SELECT id, title, claim, proof FROM lemmas WHERE id = ${id}
2013
`,
2114
sql`
2215
SELECT c.id, c.name

src/routes/lemmas/+page.server.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import type { Lemma } from '$lib/commons/types'
2+
import { query } from '$lib/server/db.catdat'
3+
import { render_nested_formulas } from '$lib/server/rendering'
4+
import { error } from '@sveltejs/kit'
5+
import sql from 'sql-template-tag'
6+
7+
export const load = async (event) => {
8+
const { rows: lemmas, err } = query<Lemma>(
9+
sql`SELECT id, title, claim, proof FROM lemmas ORDER BY id`,
10+
)
11+
12+
if (err) error(500, 'Could not load lemmas')
13+
14+
return { lemmas }
15+
}

src/routes/lemmas/+page.svelte

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<script lang="ts">
2+
import MetaData from '$components/MetaData.svelte'
3+
import SuggestionForm from '$components/SuggestionForm.svelte'
4+
5+
let { data } = $props()
6+
</script>
7+
8+
<MetaData title="Lemmas" />
9+
10+
<h2>Lemmas</h2>
11+
12+
<p class="hint">
13+
These are reusable lemmas used in multiple proofs of categorical properties in CatDat.
14+
</p>
15+
16+
<ul>
17+
{#each data.lemmas as lemma (lemma.id)}
18+
<li>
19+
<a href="/lemma/{lemma.id}">{lemma.title}</a>
20+
</li>
21+
{/each}
22+
</ul>
23+
24+
<SuggestionForm />

0 commit comments

Comments
 (0)