]> git.r.bdr.sh - rbdr/forum/blame - src/routes/t/[id].svelte
Start migration to supabase
[rbdr/forum] / src / routes / t / [id].svelte
CommitLineData
cac85db0 1<script lang="ts" context="module">
58f7d521 2 export const load = ({
cac85db0
RBR
3 page: {
4 params: { id }
5 }
58f7d521
RBR
6 }) => ({ props: { id } });
7</script>
8
cac85db0 9<script lang="ts">
58f7d521
RBR
10 import { onDestroy } from 'svelte';
11 import { _ } from 'svelte-i18n';
a7cf03c1
RBR
12 import { getTopic } from '$lib/stores/topics';
13 import { disableTopicActions, enableTopicActions } from '$lib/stores/actions';
58f7d521 14
a7cf03c1
RBR
15 import Topic from '$lib/components/topic/topic.svelte';
16 import ErrorBlock from '$lib/components/error_block/error_block.svelte';
17 import Loader from '$lib/components/loader/loader.svelte';
58f7d521 18
be1ce532 19 export let id: string;
58f7d521
RBR
20
21 $: store = getTopic(id);
22 $: topic = $store.data;
23
24 enableTopicActions(id);
25 onDestroy(() => disableTopicActions());
26</script>
27
28<svelte:head>
29 {#if $store.loading}
30 <title>{$_('loader.message')}, {$_('topic.title')}</title>
31 {/if}
32 {#if $store.error}
33 <title>{$_('error.generic.title')}, {$_('topic.title')}</title>
34 {/if}
35 {#if topic}
36 <title>{topic.title}, {$_('topic.title')}</title>
37 {/if}
38</svelte:head>
39
40{#if $store.loading}
41 <Loader />
42{/if}
43{#if $store.error}
44 <ErrorBlock message={$_('topic.error.unavailable')} />
45{/if}
46{#if topic}
47 <Topic {topic} />
48{/if}