Skip to content
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
9 changes: 7 additions & 2 deletions astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,22 @@ import mdx from '@astrojs/mdx';
import sitemap from '@astrojs/sitemap';
import rehypeAutolinkHeadings from 'rehype-autolink-headings';
import rehypeSlug from 'rehype-slug';
import rehypeUnwrapImages from 'rehype-unwrap-images';

// https://astro.build/config
export default defineConfig({
site: 'https://alex.pearwin.com',
markdown: {
rehypePlugins: [
rehypeSlug,
[rehypeAutolinkHeadings, {behaviour: "append"}],
[rehypeAutolinkHeadings, {behavior: "append"}],
rehypeUnwrapImages,
],
shikiConfig: {
theme: 'nord',
themes: {
light: 'nord',
dark: 'nord'
},
},
},
integrations: [mdx(), sitemap()],
Expand Down
44 changes: 44 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"netlify-plugin-append-redirects": "^0.0.2",
"rehype-autolink-headings": "^7.1.0",
"rehype-slug": "^6.0.0",
"rehype-unwrap-images": "^1.0.0",
"slugify": "^1.6.6",
"typescript": "^5.8.3"
},
Expand Down
Binary file added public/img/profile@1x.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/profile@2x.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 19 additions & 9 deletions src/components/Header.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,23 @@ import { SITE_TITLE } from "../consts";
---

<div class="masthead">
<h1 class="title" title="Alex Pearwin (né Alex Pearce)">
<a href="/">{SITE_TITLE}</a>
</h1>
<nav>
<ul>
<li><a href="/">About</a></li>
<li><a href="/blog/">Blog</a></li>
</ul>
</nav>
<div>
<div class="title">
<div class="profile-image">
<img
src="/img/profile@2x.jpg"
srcset="/img/profile@1x.jpg, /img/profile@2x.jpg 2x"
alt="Profile photo of Alex Pearwin">
</div>
<h1 title="Alex Pearwin (né Alex Pearce)">
<a href="/">{SITE_TITLE}</a>
</h1>
</div>
<nav>
<ul>
<li><a href="/">About</a></li>
<li><a href="/blog/">Blog</a></li>
</ul>
</nav>
</div>
</div>
18 changes: 9 additions & 9 deletions src/components/LongDate.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ export interface Props {
}

const { date } = Astro.props;

function formatDate(date: Date): string {
return date.toLocaleDateString("en-gb", {
year: "numeric",
month: "long",
day: "2-digit",
});
}
---

<time datetime={date.toISOString()}>
{
date.toLocaleDateString("en-gb", {
year: "numeric",
month: "long",
day: "2-digit",
})
}
</time>
<time datetime={date.toISOString()}>{formatDate(date)}</time>
15 changes: 9 additions & 6 deletions src/components/ShortDate.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ export interface Props {
}

const { date } = Astro.props;

function formatDate(date: Date): string {
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0'); // Months are zero-based
const day = String(date.getDate()).padStart(2, '0');

return `${year}-${month}-${day}`;
}
---

<time datetime={date.toISOString()}>
{
date.toLocaleDateString("en-gb", {
year: "numeric",
month: "short",
})
}
{formatDate(date)}
</time>
30 changes: 7 additions & 23 deletions src/layouts/BlogPost.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ import Header from "../components/Header.astro";
import Comments from "../components/Comments.astro";
import ArchivedPostBanner from "../components/ArchivedPostBanner.astro";
import LongDate from "../components/LongDate.astro";
import slugify from "../lib/slugging";

type Props = CollectionEntry<"blog">["data"];

const { title, description, date, tags, archived, comments } = Astro.props;
const { title, description, date, archived, comments } = Astro.props;
---

<html lang="en">
Expand All @@ -20,27 +19,12 @@ const { title, description, date, tags, archived, comments } = Astro.props;
<body>
<Header />
<main>
<article>
<header class="post-header">
<h1 class="post-title">{title}</h1>
<span class="post-date">Published on <LongDate date={date} /></span>
<ul class="post-tags">
{
tags.map((tag) => (
<li>
<a href={`/blog/tags/${slugify(tag)}`}>#{tag}</a>
</li>
))
}
</ul>
</header>
<div>
{archived && <ArchivedPostBanner />}
<slot />
</div>
<footer>
<a class="top" href="#">back to top ↑</a>
</footer>
<article class="contents">
<h1>{title}</h1>
<p class="post-publication">Published on <LongDate date={date}></LongDate>.</p>
{archived && <ArchivedPostBanner />}
<slot />
<a class="top" href="#">back to top ↑</a>
{comments && <Comments />}
</article>
</main>
Expand Down
23 changes: 3 additions & 20 deletions src/pages/blog/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import Header from "../../components/Header.astro";
import { SITE_TITLE, SITE_DESCRIPTION } from "../../consts";
import getPosts from "../../lib/posts";
import ShortDate from "../../components/ShortDate.astro";
import slugify from "../../lib/slugging";

const posts = await getPosts("desc");
const activePosts = posts.filter((post) => !post.data.archived);
Expand All @@ -19,8 +18,8 @@ const archivedPosts = posts.filter((post) => post.data.archived);
</head>
<body>
<Header />
<main>
<h1>Posts</h1>
<main class="contents">
<h1>Blog</h1>
<ul class="post-index">
{
activePosts.map((post) => (
Expand All @@ -36,18 +35,12 @@ const archivedPosts = posts.filter((post) => post.data.archived);
{post.data.title}
</a>
</span>
<ul class="post-tags">
{post.data.tags.map((tag) => (
<li>
<a href={`/blog/tags/${slugify(tag)}`}>#{tag}</a>
</li>
))}
</ul>
</div>
</li>
))
}
</ul>
<p>An <a href="/atom.xml">RSS feed</a> is available.</p>

<h2>Archive</h2>
<Callout>
Expand All @@ -72,21 +65,11 @@ const archivedPosts = posts.filter((post) => post.data.archived);
{post.data.title}
</a>
</span>
<ul class="post-tags">
{post.data.tags.map((tag) => (
<li>
<a href={`/blog/tags/${slugify(tag)}`}>#{tag}</a>
</li>
))}
</ul>
</div>
</li>
))
}
</ul>
<footer>
<span><a href="/atom.xml">RSS feed</a></span>
</footer>
</main>
</body>
</html>
3 changes: 1 addition & 2 deletions src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import { SITE_TITLE, SITE_DESCRIPTION } from "../consts";
</head>
<body>
<Header />
<main>
<p>Hi!</p>
<main class="contents">
<p>
I write software.
I care about what I build, why I'm building it, and how it's built.
Expand Down
Loading