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