Skip to content

Commit

Permalink
Split tags off into their own component, move tags to above author, r…
Browse files Browse the repository at this point in the history
…estyle tags
  • Loading branch information
jaasonw committed Jun 4, 2022
1 parent 145ad90 commit 0a6abfc
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
26 changes: 26 additions & 0 deletions src/lib/components/blog/tags.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<script>
export let labels;
</script>

{#if labels.length > 0}
<div class="labels">
{#each labels as label}
<small class="label">#{label}</small>
{/each}
</div>
{/if}

<style lang="scss">
.labels {
display: flex;
flex-direction: row;
flex-wrap: wrap;
gap: 0.2em;
padding-bottom: 0.5em;
small {
background-color: var(--acm-light);
border-radius: 5px;
padding: 0.3em;
}
}
</style>
8 changes: 2 additions & 6 deletions src/routes/blog/[id].svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import Spacing from '$lib/components/sections/spacing.svelte';
import { readingTime } from '$lib/blog/utils';
import { Temporal } from '@js-temporal/polyfill';
import Tags from '../../lib/components/blog/tags.svelte';
export let post: Newsletter;
</script>
Expand Down Expand Up @@ -60,12 +61,7 @@
<div class="markdown-body">
{@html post.html}
</div>

{#if post.labels.length > 0}
<small class="ita">Tags: {post.labels.join(', ')}</small>
<br />
{/if}

<Tags labels={post.labels} />
<small class="ita">Read as TXT: <a href={`${post.url}.txt`}>{post.url}.txt</a></small>
</div>

Expand Down
3 changes: 2 additions & 1 deletion src/routes/blog/index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import Spacing from '$lib/components/sections/spacing.svelte';
import { Temporal } from '@js-temporal/polyfill';
import { readingTime } from '$lib/blog/utils';
import Tags from '../../lib/components/blog/tags.svelte';
export let posts: Newsletter[] = [];
</script>
Expand Down Expand Up @@ -50,6 +51,7 @@
<div class="markdown-body">
{@html post.html}
</div>
<Tags labels={post.labels} />
<div class="author">
<a href={post.author.url}>
<img src={post.author.picture} alt="" />
Expand All @@ -67,7 +69,6 @@
</p>
</div>
</div>
<small class="ita">{post.labels.join(', ')}</small>
</a>
</li>
{/each}
Expand Down

0 comments on commit 0a6abfc

Please sign in to comment.