]>
Commit | Line | Data |
---|---|---|
1 | <script lang="ts" context="module"> | |
2 | export const load = ({ | |
3 | page: { | |
4 | params: { id } | |
5 | } | |
6 | }) => ({ props: { id } }); | |
7 | </script> | |
8 | ||
9 | <script lang="ts"> | |
10 | import { onDestroy } from 'svelte'; | |
11 | import { _ } from 'svelte-i18n'; | |
12 | import { getTopic } from '$lib/stores/topics'; | |
13 | import { disableTopicActions, enableTopicActions } from '$lib/stores/actions'; | |
14 | ||
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'; | |
18 | ||
19 | export let id: string; | |
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} |