Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restyle tags and rearrange author and read time #492

Merged
merged 3 commits into from
Jun 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/lib/components/blog/labels.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<script lang="ts">
export let data: string[] = [];
</script>

{#if data.length > 0}
<div class="labels">
{#each data 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;
font-size: 1em;
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 Labels from '$lib/components/blog/labels.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}

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

Expand Down
40 changes: 22 additions & 18 deletions 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 Labels from '$lib/components/blog/labels.svelte';

export let posts: Newsletter[] = [];
</script>
Expand Down Expand Up @@ -46,28 +47,28 @@
{#each posts as post (post.id)}
<li class="blog-post">
<a href={`/blog/${post.id}`} sveltekit:prefetch>
<h2 class="headers">{post.title}</h2>
<div class="markdown-body">
{@html post.html}
</div>
<div class="author">
<a href={post.author.url}>
<img src={post.author.picture} alt="" />
</a>
<div>
<a href={post.author.url}>{post.author.displayname}</a>
<p>
{Temporal.Instant.from(post.createdAt).toLocaleString('en-US', {
calendar: 'gregory',
year: 'numeric',
month: 'long',
day: 'numeric',
})} •
{readingTime(post.html)} min read
</p>
</div>
</div>
<small class="ita">{post.labels.join(', ')}</small>
<h2 class="headers">{post.title}</h2>
<div class="markdown-body">
{@html post.html}
</div>
<p class="read-time">
{Temporal.Instant.from(post.createdAt).toLocaleString('en-US', {
calendar: 'gregory',
year: 'numeric',
month: 'long',
day: 'numeric',
})} •
{readingTime(post.html)} min read
<Labels data={post.labels} />
</p>
</a>
</li>
{/each}
Expand Down Expand Up @@ -176,10 +177,6 @@
flex-direction: column;
}

p {
font-size: 0.8em;
}

a {
padding: 0;
font-weight: 600;
Expand All @@ -189,6 +186,13 @@
text-decoration: underline;
}
}
.read-time {
display: flex;
flex-wrap: wrap;
align-items: center;
font-size: 1em;
gap: 1em;
}
}

@media (max-width: 600px) {
Expand Down