Skip to content

Commit 0a5c48e

Browse files
committed
feat: Update article and topic pages to improve author labeling and enhance layout
1 parent 7067f1f commit 0a5c48e

3 files changed

Lines changed: 43 additions & 35 deletions

File tree

app/posts/[title]/page.tsx

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ type RouteParams = {
2323

2424
export const dynamic = "force-dynamic";
2525

26-
function buildKeywords(articleTitle: string, articleDescription: string, label: string) {
26+
function buildKeywords(
27+
articleTitle: string,
28+
articleDescription: string,
29+
label: string,
30+
) {
2731
const stopWords = new Set([
2832
"a",
2933
"an",
@@ -89,7 +93,9 @@ export async function generateMetadata({
8993

9094
const articleUrl = absoluteUrl(`/posts/${article.slug}`);
9195
const articleImage = absoluteUrl(article.img);
92-
const generatedOgImage = absoluteUrl(`/posts/${article.slug}/opengraph-image`);
96+
const generatedOgImage = absoluteUrl(
97+
`/posts/${article.slug}/opengraph-image`,
98+
);
9399
const authorUrl = article.author?.slug
94100
? absoluteUrl(`/team/${article.author.slug}`)
95101
: undefined;
@@ -172,7 +178,11 @@ export default async function ArticleDetails({
172178
datePublished: article.date.toISOString(),
173179
dateModified: article.updatedAt.toISOString(),
174180
articleSection: article.label || undefined,
175-
keywords: buildKeywords(article.title, article.description, article.label),
181+
keywords: buildKeywords(
182+
article.title,
183+
article.description,
184+
article.label,
185+
),
176186
inLanguage: "en-US",
177187
author: {
178188
"@type": "Person",
@@ -219,17 +229,27 @@ export default async function ArticleDetails({
219229
<JsonLd data={jsonLd} />
220230
<PostNavigation href="/posts">POSTS</PostNavigation>
221231

222-
<article className="grid md:grid-cols-2 gap-6 md:gap-6 pb-6 md:pb-24">
232+
<article className="grid md:grid-cols-2 gap-6 md:gap-10 pb-6 md:pb-24 items-start">
223233
<div>
224234
<h1 className="text-subtitle">{article.title}</h1>
225-
<p className="mt-4">{article.description}</p>
226235
</div>
227-
<div className="flex flex-col gap-4">
236+
237+
<div className="flex flex-col gap-6 md:gap-8">
238+
<Link
239+
href={article.topicPath}
240+
className="px-3 py-2 border border-white rounded-full w-fit h-fit hover:bg-white hover:text-black transition ml-auto"
241+
>
242+
<span className="uppercase">{article.label}</span>
243+
</Link>
244+
<p>{article.description}</p>
228245
<div className="flex flex-col sm:flex-row md:items-center gap-2 sm:gap-6">
229246
<span className="flex flex-wrap">
230-
<p className="font-semibold pr-2">Team:</p>
247+
<p className="font-semibold pr-2">Author:</p>
231248
{article.author?.slug ? (
232-
<Link href={`/team/${article.author.slug}`} className="hover:underline">
249+
<Link
250+
href={`/team/${article.author.slug}`}
251+
className="hover:underline"
252+
>
233253
{article.authorName}
234254
</Link>
235255
) : (
@@ -246,28 +266,11 @@ export default async function ArticleDetails({
246266
})}
247267
</time>
248268
</span>
249-
<span className="flex flex-wrap">
250-
<p className="font-semibold pr-2">Updated:</p>
251-
<time dateTime={article.updatedAt.toISOString()}>
252-
{article.updatedAt.toLocaleDateString("en-US", {
253-
year: "numeric",
254-
month: "long",
255-
day: "numeric",
256-
})}
257-
</time>
258-
</span>
259-
</div>
260-
<div className="flex flex-col sm:flex-row sm:items-center gap-3 sm:gap-4">
261-
<span className="flex flex-wrap">
269+
270+
<span className="flex flex-wrap items-center">
262271
<p className="font-semibold pr-2">Read:</p>
263272
<p>{article.read}</p>
264273
</span>
265-
<Link
266-
href={article.topicPath}
267-
className="px-3 py-2 border border-white rounded-full w-fit h-fit hover:bg-white hover:text-black transition"
268-
>
269-
<span className="uppercase">{article.label}</span>
270-
</Link>
271274
{article.video ? (
272275
<a
273276
href={article.video.url}
@@ -303,7 +306,7 @@ export default async function ArticleDetails({
303306
url={`/team/${article.author.slug}`}
304307
linkText="Check out"
305308
>
306-
Team
309+
Author
307310
</Subheading>
308311
<AuthorCard authorData={article.author} />
309312
</div>
@@ -347,7 +350,7 @@ export default async function ArticleDetails({
347350
<p className="mt-3 mb-12">{entry.description}</p>
348351
<div className="flex flex-wrap gap-4">
349352
<span className="flex">
350-
<p className="font-semibold pr-2">Team</p>
353+
<p className="font-semibold pr-2">Author</p>
351354
<p>{entry.authorName}</p>
352355
</span>
353356
<span className="flex">

app/topics/[topic]/page.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Suspense } from "react";
44
import Articles from "@/components/Articles/Articles";
55
import Loading from "@/components/Articles/loading";
66
import JsonLd from "@/components/JsonLd";
7+
import PageTitle from "@/components/PageTitle";
78
import {
89
type ArticleRecord,
910
getPublishedTopicBySlug,
@@ -145,11 +146,15 @@ export default async function TopicPage({
145146
return (
146147
<main className="flex flex-col min-h-screen max-w-[95rem] w-full mx-auto px-4 lg:pt-0 sm:pt-4 xs:pt-2 lg:pb-4 md:pb-4 sm:pb-2 xs:pb-2">
147148
<JsonLd data={jsonLd} />
148-
<header className="py-6 md:py-12">
149-
<p className="uppercase tracking-[0.2em] text-white/60">Topic</p>
150-
<h1 className="text-subtitle mt-4">{data.topic.label}</h1>
151-
<p className="mt-4 max-w-3xl text-white/70">{description}</p>
152-
</header>
149+
<PageTitle
150+
className="sr-only"
151+
imgSrc="/images/titles/Magazine.svg"
152+
imageWidth={1520}
153+
imageHeight={215}
154+
decorative
155+
>
156+
Tutorial Posts
157+
</PageTitle>
153158
<Suspense fallback={<Loading />}>
154159
<Articles
155160
initialArticles={mapTopicArticles(data.articles)}

components/Articles/Articles.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export default function Articles({
130130
<p className="mt-3 mb-12">{article.description}</p>
131131
<div className="flex flex-wrap gap-4">
132132
<span className="flex">
133-
<p className="font-semibold pr-2">Team</p>
133+
<p className="font-semibold pr-2">Author</p>
134134
<p>{article.authorName}</p>
135135
</span>
136136
<span className="flex">

0 commit comments

Comments
 (0)