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