Skip to content

Commit 6e4adef

Browse files
committed
feat: restructure blog and category pages, add 404 error handling, and implement subscriber form
1 parent 683c655 commit 6e4adef

8 files changed

Lines changed: 426 additions & 165 deletions

File tree

File renamed without changes.
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
---
2+
import HomeLayout from "@layouts/HomeLayout.astro";
3+
import { Image } from "astro:assets";
4+
import { getCollection, render } from "astro:content";
5+
6+
export async function getStaticPaths() {
7+
const allPosts = await getCollection("blogPosts");
8+
const catFreqs = allPosts.reduce(
9+
(acc, post) => {
10+
post.data.categories.forEach((cat) => {
11+
if (!acc[cat]) {
12+
acc[cat] = 0;
13+
}
14+
acc[cat]++;
15+
});
16+
return acc;
17+
},
18+
{} as Record<string, number>
19+
);
20+
return allPosts.map((entry) => ({
21+
params: { slug: entry.id },
22+
props: { entry, catFreqs },
23+
}));
24+
}
25+
26+
const { entry, catFreqs } = Astro.props;
27+
28+
const { Content } = await render(entry);
29+
30+
const i18n = entry.data;
31+
---
32+
33+
<HomeLayout
34+
title=`${i18n.title}`
35+
type="article"
36+
imageUrl={i18n.opengraph.image?.src}
37+
description={i18n.opengraph.description}
38+
publishedTime={i18n.createdAt?.toISOString()}
39+
modifiedTime={i18n.lastUpdatedAt?.toISOString()}
40+
author={i18n.opengraph.author}
41+
primaryCategory={i18n.categories[0]}
42+
>
43+
<article
44+
class="flex flex-col items-start justify-start bg-white text-btcgray-800 max-w-4xl mx-auto px-10 sm:px-12 lg:px-14 py-12"
45+
>
46+
<div
47+
class="flex flex-row items-center justify-start gap-2 mb-1 text-sm text-btcgray-600"
48+
>
49+
{
50+
i18n.createdAt?.toLocaleDateString("en-US", {
51+
year: "numeric",
52+
month: "long",
53+
day: "numeric",
54+
})
55+
}
56+
{
57+
i18n.lastUpdatedAt &&
58+
i18n.createdAt &&
59+
i18n.lastUpdatedAt.getDate() !== i18n.createdAt.getDate() && (
60+
<>
61+
{" "}
62+
(Updated:{" "}
63+
{i18n.lastUpdatedAt.toLocaleDateString("en-US", {
64+
year: "numeric",
65+
month: "long",
66+
day: "numeric",
67+
})}
68+
)
69+
</>
70+
)
71+
}, {i18n.opengraph.author || "Anonymous"}
72+
</div>
73+
<div class="flex flex-row flex-wrap gap-2 mt-0">
74+
{
75+
i18n.categories.map((cat) => (
76+
<a
77+
href={`/category/${cat}`}
78+
class="px-3 py-1 bg-btcgray-100 rounded-full text-sm hover:bg-btcgray-200 transition-colors"
79+
>
80+
{cat} {catFreqs[cat] > 1 ? `(${catFreqs[cat]})` : ""}
81+
</a>
82+
))
83+
}
84+
</div>
85+
<h1
86+
class="!mt-2 text-4xl font-bold text-btcgray-900 border-b-2 border-brand-500 pb-2"
87+
>
88+
{i18n.title}
89+
</h1>
90+
<div class="mt-4 mb-6">
91+
<h6 class="text-lg text-btcgray-700">
92+
{i18n.opengraph.description}
93+
</h6>
94+
</div>
95+
{
96+
i18n.opengraph.image && (
97+
<div class="flex flex-col mb-10 mt-6">
98+
<Image
99+
src={i18n.opengraph.image}
100+
alt="Cover image"
101+
class="rounded-md w-full mx-auto shadow-sm"
102+
/>
103+
<div class="flex justify-center mt-3">
104+
<p class="text-xs text-btcgray-500 italic">
105+
I had to vibe code something for this post haha. Use mouse or
106+
touch to rotate and zoom. Click "Reset View" to return to the
107+
initial angle.
108+
</p>
109+
</div>
110+
</div>
111+
)
112+
}
113+
<div class="prose prose-lg max-w-none mt-6 text-btcgray-800">
114+
<Content components={{}} />
115+
</div>
116+
</article>
117+
</HomeLayout>

website/src/content/blog-posts/distributed-key-generation/index.mdx

Lines changed: 0 additions & 19 deletions
This file was deleted.

website/src/layouts/HomeLayout.astro

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,11 @@ const {
8282
</div>
8383
<div class="flex sm:ml-6 space-x-4 sm:space-x-8">
8484
<a
85-
href="/blog"
85+
href="https://www.skeptrune.com/posts/threshold-security/"
86+
target="_blank"
8687
class="inline-flex items-center px-1 pt-1 text-sm font-medium text-btcgray-800 hover:text-brand-500"
8788
>Blog</a
8889
>
89-
<a
90-
href="/about"
91-
class="inline-flex items-center px-1 pt-1 text-sm font-medium text-btcgray-800 hover:text-brand-500"
92-
>About</a
93-
>
9490
</div>
9591
</div>
9692
</nav>

0 commit comments

Comments
 (0)