38 lines
723 B
Svelte
38 lines
723 B
Svelte
<script lang="ts">
|
|
import PostTag from '$lib/posts/PostTag.svelte';
|
|
import EmptyCard from './EmptyCard.svelte';
|
|
|
|
async function fetchTags() {
|
|
const tags: string[] = [];
|
|
const endpoint = '/posts/tag/all';
|
|
const res = await fetch(endpoint);
|
|
const json = await res.json();
|
|
if (Array.isArray(json)) {
|
|
for (const item of json) {
|
|
tags.push(item);
|
|
}
|
|
}
|
|
return tags;
|
|
}
|
|
</script>
|
|
|
|
<EmptyCard>
|
|
{#await fetchTags()}
|
|
<p class="message">Loading Tags...</p>
|
|
{:then tags}
|
|
{#each tags as tag}
|
|
<div class="tag-link">
|
|
<PostTag {tag} />
|
|
</div>
|
|
{/each}
|
|
{:catch}
|
|
<p class="message">Unable to load tags</p>
|
|
{/await}
|
|
</EmptyCard>
|
|
|
|
<style>
|
|
.message {
|
|
color: var(--light-text-color);
|
|
}
|
|
</style>
|