diff options
| author | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2021-04-15 23:06:26 +0200 |
|---|---|---|
| committer | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2021-04-15 23:06:26 +0200 |
| commit | 58f7d52150456713d3132408668a92d0f6f3d084 (patch) | |
| tree | 4b346042a684e416e53c4f4ac779060b832ad227 /src/components/topic | |
| parent | 63c3da2af27fcfb1a9893ade03543e3a30949c8d (diff) | |
Port to sveltekit
Diffstat (limited to 'src/components/topic')
| -rw-r--r-- | src/components/topic/topic.svelte | 80 |
1 files changed, 39 insertions, 41 deletions
diff --git a/src/components/topic/topic.svelte b/src/components/topic/topic.svelte index 9be7346..181b429 100644 --- a/src/components/topic/topic.svelte +++ b/src/components/topic/topic.svelte @@ -1,46 +1,44 @@ <script> - export let id; + export let topic; - import { _ } from 'svelte-i18n'; - import { getTopic } from '$/stores/topic'; + import { _ } from 'svelte-i18n'; + import Post from '$/components/post/post.svelte'; + import { readableTime } from '$/utils/readable_time.js'; - import ErrorBlock from '$/components/error_block/error_block.svelte'; - import Loader from '$/components/loader/loader.svelte'; - import PostContent from '$/components/post_content/post_content.svelte'; - import { readableTime } from '$/utils/readable_time.js'; - - $: store = getTopic(id); - $: topic = $store.data; - $: remainingTime = topic ? (topic.updated_at + topic.ttl) - Date.now() : 0; - $: remaining = readableTime(remainingTime); + $: remainingTime = topic ? topic.updated_at + topic.ttl - Date.now() : 0; + $: remaining = readableTime(remainingTime); </script> -{#if $store.loading} - <Loader /> -{/if} -{#if $store.error} - <ErrorBlock message={$_('topic.error.unavailable')} /> -{/if} -{#if topic} - <div class="h-entry" title="{$_('topic.title')}"> - <h1 class="p-name">{topic.title}</h1> - <aside class="topic-meta" title="{$_('topic.metadata_title')}"> - {#if topic.forum} - <span class="topic-location">{$_('topic.category_location')} <a href="/f/{topic.forum.id}" - class="p-category">{topic.forum.glyph} {$_(topic.forum.label)}</a>.</span> - {/if} - <span class="topic-ttl"><a class="u-url u-uid" title="{$_('topic.permalink_title')}" href="/t/{topic.id}">({$_('topic.remaining_time', { values: { remaining: $_(remaining.label, { values: { count: remaining.count } }) } })})</a>.</span> - </aside> - {#if topic.tags.length > 0} - <aside class="topic-tags" title="{$_('topic.tags_title')}"> - {$_('topic.tags_location')} - {#each topic.tags as tag} - <a href="/g/{tag.id}" class="p-category">{tag.id}<span class="tag-weight">({tag.weight})</span></a>{' '} - {/each} - </aside> - {/if} - {#each topic.posts as post, index} - <PostContent post={post} index={index} count={topic.posts.length} /> - {/each} - </div> -{/if} +<div class="h-entry" title={$_('topic.title')}> + <h1 class="p-name">{topic.title}</h1> + <aside class="topic-meta" title={$_('topic.metadata_title')}> + {#if topic.forum} + <span class="topic-location" + >{$_('topic.category_location')} + <a href="/f/{topic.forum.id}" class="p-category" + >{topic.forum.glyph} {$_(topic.forum.label)}</a + >.</span + > + {/if} + <span class="topic-ttl" + ><a class="u-url u-uid" title={$_('topic.permalink_title')} href="/t/{topic.id}" + >({$_('topic.remaining_time', { + values: { remaining: $_(remaining.label, { values: { count: remaining.count } }) } + })})</a + >.</span + > + </aside> + {#if topic.tags.length > 0} + <aside class="topic-tags" title={$_('topic.tags_title')}> + {$_('topic.tags_location')} + {#each topic.tags as tag} + <a href="/g/{tag.id}" class="p-category" + >{tag.id}<span class="tag-weight">({tag.weight})</span></a + >{' '} + {/each} + </aside> + {/if} + {#each topic.posts as post, index} + <Post {post} {index} count={topic.posts.length} /> + {/each} +</div> |