Skip to content

Commit 0a2825e

Browse files
committed
Parse and list blog posts
1 parent f0ae138 commit 0a2825e

File tree

15 files changed

+3012
-316
lines changed

15 files changed

+3012
-316
lines changed

app/blog/[id]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { Fira_Code, Lexend_Zetta } from 'next/font/google'
33
import { notFound } from 'next/navigation'
44

55
import Section from '/components/Section/Section'
6-
import { fetchPost } from '/services/blog'
76
import Nav from '../../../components/Nav'
87
import Socials from '../../../components/Socials'
8+
import { fetchPost } from '../../../utils/blog'
99

1010
import styles from './page.module.scss'
1111

app/page.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1+
import { BlogEntry } from '/components/BlogEntry'
12
import { DesignWork } from '/components/DesignWork'
23
import { Eyes } from '/components/Eyes'
34
import { ProjectCard } from '/components/ProjectCard'
45
import { Socials } from '/components/Socials'
56
import { DESIGN_WORK } from '/res/designWork'
67
import { PROJECTS } from '/res/projects'
8+
import { fetchBlogPosts } from '/utils/blog'
79
import { AllProjects } from './projects'
810

911
const projectCards = PROJECTS.map((project) => <ProjectCard key={project.name} {...project} />)
1012

1113
const Home = async () => {
14+
const posts = await fetchBlogPosts()
15+
1216
return (
1317
<>
1418
<header className="relative flex min-h-[80vh] items-center justify-center overflow-hidden px-12 py-20">
@@ -60,10 +64,14 @@ const Home = async () => {
6064
))}
6165
</section>
6266

63-
<section className="bg-light px-gutter pb-14 text-dark">
64-
<h1 className="mb-10 text-4xl">Blog</h1>
65-
{/* {blogPosts?.posts.map((post) => <BlogEntry key={post.id} {...post} />) ?? <p>Failed to load blog posts</p>} */}
66-
</section>
67+
{posts.length > 0 && (
68+
<section className="bg-light pb-14 text-dark">
69+
<h1 className="mb-10 px-gutter text-4xl">Blog</h1>
70+
{posts.map((post) => (
71+
<BlogEntry key={post.slug} number={post.number} slug={post.slug} title={post.title} />
72+
))}
73+
</section>
74+
)}
6775
</main>
6876

6977
<footer className="px-gutter py-16 text-center">

components/BlogEntry/BlogEntry.module.scss

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

components/BlogEntry/BlogEntry.tsx

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

components/BlogEntry/index.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { Lexend_Zetta } from 'next/font/google'
2+
import Link from 'next/link'
3+
4+
const lexendZetta = Lexend_Zetta({ subsets: ['latin'] })
5+
6+
interface BlogEntryProps {
7+
slug: string
8+
number: number
9+
title: string
10+
}
11+
12+
export const BlogEntry = ({ slug, number, title }: BlogEntryProps) => {
13+
return (
14+
<Link href={`/blog/${slug}`} className="!no-underline group">
15+
<article className="flex items-center gap-3 pr-gutter">
16+
<span
17+
className={`${lexendZetta.className} block bg-[length:200%_100%] bg-gradient-to-r from-50% from-dark to-50% to-transparent bg-no-repeat py-4 pr-3 pl-gutter font-black text-2xl transition-[background-position-x,color] [background-position-x:100%] group-hover:text-light group-hover:[background-position-x:0]`}
18+
>
19+
{number.toString().padStart(2, '0')}
20+
</span>
21+
<span className="underline transition-[font-weight] group-hover:font-semibold">{title}</span>
22+
</article>
23+
</Link>
24+
)
25+
}

components/ProjectCard/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useId } from 'react'
22
import type { Project as ProjectProps } from '/res/projects'
3+
import { getS3Url } from '/utils/getS3Url'
34

45
export const ProjectCard = ({ name, description, image, href }: ProjectProps) => {
56
const id = useId()
@@ -13,7 +14,7 @@ export const ProjectCard = ({ name, description, image, href }: ProjectProps) =>
1314
>
1415
<article>
1516
<img
16-
src={`https://benji-portfolio.s3.ap-southeast-2.amazonaws.com/Portfolio/Projects/${image.src}`}
17+
src={getS3Url(`Portfolio/Projects/${image.src}`)}
1718
alt={image.alt}
1819
className="aspect-video w-full rounded-2xl bg-current object-cover"
1920
/>

env.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { createEnv } from '@t3-oss/env-nextjs'
2+
import { z } from 'zod'
3+
4+
export const env = createEnv({
5+
server: {
6+
AWS_ACCESS_KEY: z.string().min(1),
7+
AWS_SECRET_KEY: z.string().min(1),
8+
},
9+
client: {
10+
NEXT_PUBLIC_AWS_REGION: z.string().min(1),
11+
NEXT_PUBLIC_AWS_BUCKET: z.string().min(1),
12+
},
13+
experimental__runtimeEnv: {
14+
NEXT_PUBLIC_AWS_REGION: process.env.NEXT_PUBLIC_AWS_REGION,
15+
NEXT_PUBLIC_AWS_BUCKET: process.env.NEXT_PUBLIC_AWS_BUCKET,
16+
},
17+
})

next.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import type { NextConfig } from 'next'
22

3+
// Validate env variables
4+
import '/env'
5+
36
const nextConfig: NextConfig = {
47
poweredByHeader: false,
58
experimental: {

package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,27 @@
1010
"format": "biome check --fix"
1111
},
1212
"dependencies": {
13+
"@aws-sdk/client-s3": "^3.717.0",
1314
"@biomejs/biome": "^1.9.4",
15+
"@portaljs/remark-wiki-link": "^1.2.0",
16+
"@t3-oss/env-nextjs": "^0.11.1",
1417
"@tailwindcss/postcss": "4.0.0-beta.8",
1518
"@types/node": "22.10.2",
1619
"@types/poisson-disk-sampling": "2.2.4",
1720
"@types/react": "19.0.2",
1821
"@types/react-dom": "19.0.2",
1922
"babel-plugin-react-compiler": "19.0.0-beta-b2e8e9c-20241220",
2023
"next": "15.1.2",
24+
"next-mdx-remote": "^5.0.0",
2125
"poisson-disk-sampling": "2.3.1",
2226
"react": "19.0.0",
2327
"react-dom": "19.0.0",
28+
"remark-gfm": "^4.0.0",
2429
"schema-dts": "^1.1.2",
2530
"tailwind-merge": "^2.6.0",
2631
"tailwindcss": "4.0.0-beta.8",
27-
"typescript": "5.7.2"
32+
"typescript": "5.7.2",
33+
"zod": "^3.24.1"
2834
},
2935
"packageManager": "[email protected]+sha256.9e534e70afef06374f6126b44bda5760947135ce16a30aef1010e965fb7e3e3e"
3036
}

0 commit comments

Comments
 (0)