Skip to content

Commit

Permalink
Add content to home page
Browse files Browse the repository at this point in the history
  • Loading branch information
eliperkins committed Apr 25, 2024
1 parent ea41051 commit 7bac540
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 8 deletions.
7 changes: 5 additions & 2 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,18 @@ export default async function Home() {
<main>
<MainHeader />
<Bio />
<ul className="prose md:prose-lg lg:prose-xl font-serif prose-a:font-semibold prose-a:underline-offset-4 prose-a:text-amber-600 hover:prose-a:text-amber-700">
<ul className="prose md:prose-lg lg:prose-xl font-serif prose-a:font-semibold prose-a:underline-offset-4 prose-a:text-amber-600 hover:prose-a:text-amber-700 prose-h3:mb-0 prose-p:my-0">
{posts.map((post) => (
<li key={post.slug}>
<h3 >
<h3>
<Link href={post.slug}>{post.title}</Link>
</h3>
<time dateTime={post.date} className="text-sm lg:text-base">
{format(post.date, 'MMMM dd, yyyy')}
</time>
{post.excerpt && (
<div dangerouslySetInnerHTML={{ __html: post.excerpt}} />
)}
</li>
))}
</ul>
Expand Down
27 changes: 21 additions & 6 deletions lib/posts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ type Post = {
title: string;
date: string;
slug: string;
content: string;
excerpt: string;
};

type FrontMatter = {
title: string;
date: string;
excerpt: string;
};

export async function fetchPosts(): Promise<Post[]> {
Expand All @@ -35,26 +43,33 @@ async function parsePostFile(slug: string): Promise<VFile> {
export async function fetchPost(slug: string): Promise<Post> {
const file = await parsePostFile(slug);

const { title, date }: { title: string; date: string } = file.data
.matter as any;
const { title, date, excerpt }: FrontMatter = file.data.matter as any;

const content = await fetchPostContent(slug);
const parsedExcerpt = await parseMarkdownContent(excerpt);

return {
title,
date,
slug,
content,
excerpt: parsedExcerpt,
};
}

export async function fetchPostContent(slug: string): Promise<string> {
const file = await parsePostFile(slug);

async function parseMarkdownContent(content: string): Promise<string> {
const output = await unified()
.use(remarkParse)
.use(remarkGfm)
.use(remarkRehype, { allowDangerousHtml: true })
.use(rehypeHighlight)
.use(rehypeStringify, { allowDangerousHtml: true })
.process(String(file));
.process(String(content));

return String(output);
}

export async function fetchPostContent(slug: string): Promise<string> {
const file = await parsePostFile(slug);
return parseMarkdownContent(String(file));
}
1 change: 1 addition & 0 deletions posts/get-off-my-lawn/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: Get Off My Lawn
date: 2014-02-13
excerpt: Respect each other's opinions in the iOS community and let's focus on creating cool things with the tools we like.
---

There's been a lot of drama among the iOS community these
Expand Down
1 change: 1 addition & 0 deletions posts/how-we-learn/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: How We Learn
date: 2014-02-04
excerpt: Find success by seeking to learn more, shaping one's own personal opinion, and changing one's mind.
---

> He said people who were right a lot of the time _were
Expand Down
1 change: 1 addition & 0 deletions posts/mocks-in-swift-via-protocols/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: Mocks in Swift via Protocols
date: 2015-10-01
excerpt: How to use protocols to mock types in Swift to test your iOS apps without relying on Objective-C runtime hacks and swizzles.
---

Testing the nitty gritty dirty innards of a lot of iOS apps
Expand Down
1 change: 1 addition & 0 deletions posts/se0117-has-the-power-to-change-sdk-design/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: SE-0117, API Design, and You
date: 2016-07-19
excerpt: Use composition over inheritance. Pass values into functions.
---

A lot of conversation has been going around about
Expand Down
2 changes: 2 additions & 0 deletions posts/what-is-relay-validate/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: Validating Relay Queries With This One Weird Trick™
date: 2019-03-22
excerpt: |
tl;dr: Use `relay --validate` to catch Relay validation errors in CI.
---

> tl;dr: Use `relay --validate` to catch Relay validation
Expand Down
1 change: 1 addition & 0 deletions posts/wwdc-2014-predictions/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: WWDC 2014 Predictions
date: 2014-05-28
excerpt: Boy, was I wrong... maybe?
---

I figured I'd put my hat in the ring here.
Expand Down

0 comments on commit 7bac540

Please sign in to comment.