mirror of https://github.com/almqv/wych.dev
parent
b59ded9c0d
commit
84e6c24472
@ -1,67 +1,87 @@ |
|||||||
import ThingCurve from "@/components/3d/curves/thing"; |
|
||||||
import RenderedSection from "@/components/3d/renderedsection"; |
|
||||||
import AgeHCyclesDisplay from "@/components/age"; |
|
||||||
import ExternalNav from "@/components/externalnav"; |
import ExternalNav from "@/components/externalnav"; |
||||||
import fonts from "@/components/fonts"; |
|
||||||
import ILink from "@/components/ilink"; |
import ILink from "@/components/ilink"; |
||||||
import { |
import fs from 'fs/promises'; |
||||||
Card, |
import path from 'path'; |
||||||
CardContent, |
import matter from 'gray-matter'; |
||||||
CardDescription, |
import Link from 'next/link'; |
||||||
CardHeader, |
|
||||||
CardTitle, |
type PostMeta = { |
||||||
} from "@/components/ui/card"; |
title: string; |
||||||
import { cn } from "@/lib/utils"; |
createdAt: string; |
||||||
|
slug: string; |
||||||
|
}; |
||||||
|
|
||||||
|
async function getRecentPosts(): Promise<PostMeta[]> { |
||||||
|
const postsDirectory = path.join(process.cwd(), 'content/essays'); |
||||||
|
const files = await fs.readdir(postsDirectory); |
||||||
|
|
||||||
|
const posts = await Promise.all( |
||||||
|
files |
||||||
|
.filter(file => file.endsWith('.mdx')) |
||||||
|
.map(async (file) => { |
||||||
|
const fullPath = path.join(postsDirectory, file); |
||||||
|
const fileContents = await fs.readFile(fullPath, 'utf8'); |
||||||
|
const { data } = matter(fileContents); |
||||||
|
|
||||||
|
return { |
||||||
|
title: data.title, |
||||||
|
createdAt: data.createdAt, |
||||||
|
slug: file.replace(/\.mdx$/, ''), |
||||||
|
}; |
||||||
|
}) |
||||||
|
); |
||||||
|
|
||||||
|
return posts |
||||||
|
.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()) |
||||||
|
.slice(0, 2); // Get only the 2 most recent posts
|
||||||
|
} |
||||||
|
|
||||||
|
export default async function Home() { |
||||||
|
const recentPosts = await getRecentPosts(); |
||||||
|
|
||||||
export default function Home() { |
|
||||||
return ( |
return ( |
||||||
<div className="w-full h-full overflow-y-clip"> |
<main className="w-full flex justify-center px-4"> |
||||||
<RenderedSection |
<div className="w-full max-w-prose py-8 space-y-8"> |
||||||
id="about" |
{/* Intro */} |
||||||
curve={ThingCurve} |
<section> |
||||||
className="relative w-full h-full px-4 md:px-8 max-w-screen-2xl items-center flex" |
<h1 className="text-2xl font-bold mb-4">Elias Almqvist</h1> |
||||||
curveClassname="w-[38rem] h-[52rem] xl:w-[58rem] xl:h-[82rem] absolute -top-16 xl:-top-48 -right-32 lg:-right-12 2xl:right-32 overflow-clip" |
<p className="text-gray-600 dark:text-gray-300"> |
||||||
> |
CEO of{" "} |
||||||
<Card className="max-w-screen-md"> |
<ILink href="https://exalaboratories.com" target="_blank"> |
||||||
<CardHeader> |
Exa Laboratories (YC S24) |
||||||
<CardTitle>Elias Almqvist</CardTitle> |
</ILink> |
||||||
<CardDescription className="pl-0 space-y-4"> |
. Building energy-efficient chips for AI training & inference. |
||||||
<span className="inline-block"> |
</p> |
||||||
I am a{" "} |
</section> |
||||||
{ |
|
||||||
<AgeHCyclesDisplay |
{/* Recent Essays */} |
||||||
className={cn("font-bold", fonts.mono.className)} |
<section> |
||||||
precision={12} |
<div className="flex justify-between items-center mb-4"> |
||||||
/> |
<h2 className="text-xl font-semibold">Recent Essays</h2> |
||||||
}{" "} |
<Link href="/essays" className="text-sm text-gray-500 hover:text-gray-700"> |
||||||
<span className="font-bold">hydrogen-line-cycles</span>{" "} |
View all → |
||||||
<span className="text-xs text-foreground/40">(± 2 mHz)</span>{" "} |
</Link> |
||||||
old <span className="font-bold">human-</span> founder, engineer, |
</div> |
||||||
and hacker with a passion for CS, physics, and mathematics. |
<ul className="space-y-4"> |
||||||
</span> |
{recentPosts.map((post) => ( |
||||||
<span className="inline-block"> |
<li key={post.slug}> |
||||||
CEO of{" "} |
<Link
|
||||||
<ILink href="https://exalaboratories.com" target="_blank"> |
href={`/essays/${post.slug}`} |
||||||
Exa Laboratories (YC S24) |
className="block hover:bg-gray-50 dark:hover:bg-gray-800 p-4 rounded-lg transition" |
||||||
</ILink> |
> |
||||||
. Some of my projects are open-source (FOSS), and if you are |
<h3 className="font-medium">{post.title}</h3> |
||||||
interested, you can find them on my{" "} |
<time className="text-sm text-gray-500"> |
||||||
<ILink href="https://git.wych.dev/elal" target="_blank"> |
{new Date(post.createdAt).toLocaleDateString()} |
||||||
self-hosted git-server |
</time> |
||||||
</ILink>{" "} |
</Link> |
||||||
or{" "} |
</li> |
||||||
<ILink href="https://github.com/almqv" target="_blank"> |
))} |
||||||
GitHub |
</ul> |
||||||
</ILink> |
</section> |
||||||
. |
|
||||||
</span> |
{/* External Links */} |
||||||
</CardDescription> |
<ExternalNav className="flex gap-4" /> |
||||||
<CardContent className="flex flex-col items-center justify-center pb-0 pt-4"> |
</div> |
||||||
<ExternalNav className="w-full max-w-48 flex flex-row justify-between" /> |
</main> |
||||||
</CardContent> |
|
||||||
</CardHeader> |
|
||||||
</Card> |
|
||||||
</RenderedSection> |
|
||||||
</div> |
|
||||||
); |
); |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue