]> git.r.bdr.sh - rbdr/forum/commitdiff
Add tag component:
authorRuben Beltran del Rio <redacted>
Sun, 14 Mar 2021 22:08:44 +0000 (23:08 +0100)
committerRuben Beltran del Rio <redacted>
Sun, 14 Mar 2021 22:08:44 +0000 (23:08 +0100)
src/components/tag/tag.svelte [new file with mode: 0644]
src/components/topic_summary/topic_summary.svelte

diff --git a/src/components/tag/tag.svelte b/src/components/tag/tag.svelte
new file mode 100644 (file)
index 0000000..a14cd19
--- /dev/null
@@ -0,0 +1,27 @@
+<script>
+  export let id;
+
+  import { _ } from 'svelte-i18n';
+  import { getTag } from '$/stores/tag';
+  import ErrorBlock from '$/components/error_block/error_block.svelte';
+  import Loader from '$/components/loader/loader.svelte';
+  import TopicSummary from '$/components/topic_summary/topic_summary.svelte';
+
+  $: store = getTag(id);
+  $: tag = $store.data;
+</script>
+
+{#if $store.loading}
+  <Loader />
+{/if}
+{#if $store.error}
+  <ErrorBlock message={$_('tag.error.unavailable')} />
+{/if}
+{#if tag}
+  <h1>{$_('tag.title')} {tag.id}</h1>
+  <ul>
+    {#each tag.topics as topic}
+      <TopicSummary topic={topic} />
+    {/each}
+  </ul>
+{/if}
index deef3e2197c8c7dac5784d9323ff18d1ceae8d03..88b2b83232dcae2fed43f8539c97c406692bd462 100644 (file)
@@ -2,7 +2,7 @@
   export let topic;
 
   import { _ } from 'svelte-i18n';
   export let topic;
 
   import { _ } from 'svelte-i18n';
-  import { readableTime } from '../../utils/readable_time.js';
+  import { readableTime } from '$/utils/readable_time.js';
 
   $: remainingTime = (topic.updated_at + topic.ttl) - Date.now();
   $: remaining = readableTime(remainingTime);
 
   $: remainingTime = (topic.updated_at + topic.ttl) - Date.now();
   $: remaining = readableTime(remainingTime);