thomaswilson-sveltekit/src/routes/blog/+page.svelte

153 lines
3.7 KiB
Svelte
Raw Normal View History

2022-04-16 10:43:45 +00:00
<script lang="ts">
import type { PageData } from "./$types.js";
2023-01-30 22:30:38 +00:00
import Navbar from "$lib/components/Navbar.svelte";
import BlogPostListItem from "./BlogPostListItem.svelte";
2023-01-30 22:30:38 +00:00
2025-01-04 15:35:07 +00:00
interface Props {
data: PageData;
}
2025-01-04 15:35:07 +00:00
let { data }: Props = $props();
let {
2023-01-30 22:30:38 +00:00
posts,
numberOfPosts,
daysSinceLastPublish,
daysSinceFirstPost,
averageDaysBetweenPosts,
numberOfBlogPostsThisYear,
2025-01-04 15:35:07 +00:00
} = $derived(data);
2022-04-16 10:43:45 +00:00
</script>
<svelte:head>
2023-01-30 22:30:38 +00:00
<!-- Primary Meta Tags -->
<title>Blog | thomaswilson.xyz</title>
<meta name="title" content="Blog | thomaswilson.xyz" />
<meta
name="description"
content="I write about software and how I should have built it, and sometimes other things."
/>
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website" />
<meta property="og:url" content="https://www.thomaswilson.xyz/blog" />
<meta property="og:title" content="Blog | thomaswilson.xyz" />
<meta
property="og:description"
content="I write about software and how I should have built it, and sometimes other things."
/>
<!-- Twitter -->
<meta property="twitter:title" content="Blog | thomaswilson.xyz" />
<meta
property="twitter:description"
content="I write about software and how I should have built it, and sometimes other things."
/>
</svelte:head>
2022-04-16 10:43:45 +00:00
<Navbar />
<main class="thomaswilson-container">
2024-06-18 06:23:06 +00:00
<section class="thomaswilson-strapline section heading">
2025-01-04 15:28:36 +00:00
<h1 class="page-title">Blog</h1>
2024-06-18 06:23:06 +00:00
<p class="heading__text">
It has been been
<span
2023-01-30 22:30:38 +00:00
class="days-since"
2024-06-18 06:23:06 +00:00
class:days-since-success={daysSinceLastPublish === 0}
2023-01-30 22:30:38 +00:00
>
{daysSinceLastPublish}
</span>
{daysSinceLastPublish === 1 ? "day" : "days"} since I last published something.
</p>
2024-06-18 06:23:06 +00:00
<p class="heading__text">
I have written {numberOfBlogPostsThisYear}
{numberOfBlogPostsThisYear === 1 ? "piece" : "pieces"} so far this year. On
average I publish something every {averageDaysBetweenPosts} days ({numberOfPosts}
2023-01-30 22:30:38 +00:00
posts in {daysSinceFirstPost} days).
</p>
2023-02-12 10:16:13 +00:00
<a href="/blog/feed">RSS Feed</a>
2023-01-30 22:30:38 +00:00
</section>
<section class="section">
<h2>All Writing</h2>
<ul class="posts">
{#each posts as post, index}
<BlogPostListItem
2024-06-18 06:23:06 +00:00
{index}
content_type={post.content_type}
book_review={post.book_review}
date={post.date}
numberOfPosts={posts.length}
preview={post.preview}
slug={post.slug}
title={post.title}
/>
{/each}
2023-01-30 22:30:38 +00:00
</ul>
</section>
2022-04-16 10:43:45 +00:00
</main>
2023-02-14 23:00:25 +00:00
<style lang="scss">
2025-01-04 15:28:36 +00:00
.page-title {
font-size: 2.5rem;
margin: 0;
line-height: 100%;
}
2024-06-18 06:23:06 +00:00
.heading {
2025-01-04 15:28:36 +00:00
padding: 0;
2024-06-18 06:23:06 +00:00
gap: var(--spacing-base);
display: grid;
grid-template-columns: 100%;
}
2025-01-04 15:28:36 +00:00
.heading__text {
font-family: sans-serif;
margin: 0;
line-height: 150%;
font-size: 1.25rem;
}
2023-01-30 22:30:38 +00:00
.posts {
list-style: none;
margin: 0;
padding: 0;
display: grid;
grid-template-columns: 100%;
2025-01-04 15:28:36 +00:00
gap: var(--spacing-xl);
2023-01-30 22:30:38 +00:00
max-width: 100%;
}
.days-since {
color: var(--brand-orange);
font-weight: 300;
border: 1px solid var(--brand-orange);
border-radius: 4px;
padding: 8px;
2025-01-04 15:28:36 +00:00
margin: 0 4px;
2023-01-30 22:30:38 +00:00
font-family: monospace;
2025-01-04 15:28:36 +00:00
font-size: inherit;
2023-01-30 22:30:38 +00:00
}
.days-since-success {
color: var(--brand-green);
border: 1px solid var(--brand-green);
animation-name: pulse_green;
animation-duration: 5.2s;
animation-iteration-count: infinite;
background: rgba(54, 130, 127, 0.05);
}
@keyframes pulse_green {
0% {
box-shadow: 0 0 0 0px rgba(54, 130, 127, 1);
}
20%,
100% {
box-shadow: 0 0 0 5px rgba(54, 130, 127, 0);
}
}
2022-04-16 10:43:45 +00:00
</style>