Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

feat: new author page on blog (#41281)

Alan Danielcb97fa7eb320
diff --git a/apps/www/app/blog/authors/[author]/AuthorClient.tsx b/apps/www/app/blog/authors/[author]/AuthorClient.tsx
new file mode 100644
index 00000000000..65359179887
--- /dev/null
+++ b/apps/www/app/blog/authors/[author]/AuthorClient.tsx
@@ -0,0 +1,168 @@
+'use client'
+
+import { useState, useMemo } from 'react'
+import Link from 'next/link'
+import Image from 'next/image'
+import DefaultLayout from 'components/Layouts/Default'
+import BlogGridItem from 'components/Blog/BlogGridItem'
+import BlogListItem from 'components/Blog/BlogListItem'
+import { cn, Button, Input } from 'ui'
+import { LOCAL_STORAGE_KEYS, isBrowser } from 'common'
+import { AlignJustify, Grid, Search } from 'lucide-react'
+
+import type PostTypes from 'types/post'
+
+export type BlogView = 'list' | 'grid'
+
+interface Author {
+ author_id: string
+ author: string
+ position?: string
+ author_url?: string
+ author_image_url?: string
+}
+
+interface AuthorClientProps {
+ author: Author | null
+ authorId: string
+ blogs: PostTypes[]
+}
+
+export default function AuthorClient({ author, authorId, blogs }: AuthorClientProps) {
+ const { BLOG_VIEW } = LOCAL_STORAGE_KEYS
+ const localView = isBrowser ? (localStorage?.getItem(BLOG_VIEW) as BlogView) : undefined
+ const [view, setView] = useState<BlogView>(localView ?? 'list')
+ const [searchTerm, setSearchTerm] = useState('')
+ const isList = view === 'list'
+
+ const filteredBlogs = useMemo(() => {
+ if (!searchTerm) return blogs
+ const term = searchTerm.toLowerCase()
+ return blogs.filter(
+ (blog) =>
+ (blog.title ?? '').toLowerCase().includes(term) ||
+ (blog.description ?? '').toLowerCase().includes(term)
+ )
+ }, [blogs, searchTerm])
+
+ const handleViewSelection = () => {
+ setView((prevView) => {
+ const newValue = prevView === 'list' ? 'grid' : 'list'
+ localStorage.setItem(BLOG_VIEW, newValue)
+ return newValue
+ })
+ }
+
+ return (
+ <DefaultLayout>
+ <div className="container mx-auto px-4 py-4 md:py-8 xl:py-10 sm:px-16 xl:px-20">
+ <div className="text-foreground-lighter flex space-x-1 mb-8">
+ <h1 className="cursor-pointer">
+ <Link href="/blog">Blog</Link>
+ <span className="px-2">/</span>
+ <span className="text-foreground">{author?.author ?? authorId}</span>
+ </h1>
+ </div>
+
+ {author && (
+ <div className="flex items-center gap-6 pb-8">
+ {author.author_image_url && (
+ <Image
+ src={author.author_image_url}
+ alt={`${author.author} avatar`}
+ width={80}
+ height={80}
+ className="rounded-full border border-default"
+ />
+ )}
+ <div className="flex flex-col gap-1">
+ <h2 className="text-2xl text-foreground">{author.author}</h2>
+ {author.position && <p className="text-foreground-light">{author.position}</p>}
+ {author.author_url && (
+ <Link
+ href={author.author_url}
+ target="_blank"
+ className="text-brand hover:underline text-sm"
+ >
+ {author.author_url.includes('github.com')
+ ? 'GitHub'
+ : author.author_url.includes('twitter.com') ||
+ author.author_url.includes('x.com')
+ ? 'Twitter'
+ : author.author_url.includes('linkedin.com')
+ ? 'LinkedIn'
+ : 'Website'}
+ </Link>
+ )}
+ </div>
+ </div>
+ )}
+ </div>
+
+ <div className="border-default border-t">
+ <div className="container mx-auto px-4 py-4 md:py-8 xl:py-10 sm:px-16 xl:px-20">
+ <div className="flex flex-row items-center justify-between gap-2 mb-6">
+ <div className="flex-1 max-w-[280px]">
+ <Input
+ icon={<Search size="14" />}
+ size="small"
+ layout="vertical"
+ autoComplete="off"
+ type="search"
+ placeholder="Search posts"
+ value={searchTerm}
+ onChange={(e) => setSearchTerm(e.target.value)}
+ className="w-full"
+ />
+ </div>
+ <Button
+ type="default"
+ title={isList ? 'Grid View' : 'List View'}
+ onClick={handleViewSelection}
+ className="h-full p-2 text-foreground-light"
+ >
+ {isList ? (
+ <Grid className="w-4 h-4 stroke-1.5" />
+ ) : (
+ <AlignJustify className="w-4 h-4 stroke-1.5" />
+ )}
+ </Button>
+ </div>
+
+ {filteredBlogs.length > 0 ? (
+ <ol
+ className={cn(
+ 'grid -mx-2 sm:-mx-4 py-6 lg:py-6 lg:pb-20',
+ isList ? 'grid-cols-1' : 'grid-cols-12 lg:gap-4'
+ )}
+ >
+ {filteredBlogs.map((blog: PostTypes, idx: number) =>
+ isList ? (
+ <div
+ className="col-span-12 px-2 sm:px-4 [&_a]:last:border-none"
+ key={`list-${idx}-${blog.slug}`}
+ >
+ <BlogListItem post={blog} />
+ </div>
+ ) : (
+ <div
+ className="col-span-12 mb-4 md:col-span-12 lg:col-span-6 xl:col-span-4 h-full"
+ key={`grid-${idx}-${blog.slug}`}
+ >
+ <BlogGridItem post={blog} />
+ </div>
+ )
+ )}
+ </ol>
+ ) : (
+ <p className="text-foreground-lighter py-8">
+ {searchTerm
+ ? 'No posts found matching your search.'
+ : 'No posts found by this author.'}
+ </p>
+ )}
+ </div>
+ </div>
+ </DefaultLayout>
+ )
+}
diff --git a/apps/www/app/blog/authors/[author]/page.tsx b/apps/www/app/blog/authors/[author]/page.tsx
new file mode 100644
index 00000000000..29297b45bb7
--- /dev/null
+++ b/apps/www/app/blog/authors/[author]/page.tsx
@@ -0,0 +1,71 @@
+import type { Metadata } from 'next'
+
+import blogAuthors from 'lib/authors.json'
+import { getAllCMSPosts } from 'lib/get-cms-posts'
+import { getSortedPosts } from 'lib/posts'
+import type PostTypes from 'types/post'
+import AuthorClient from './AuthorClient'
+
+type Params = { author: string }
+
+// Build a lookup map from any identifier (author_id or username) to canonical author_id
+const authorIdLookup = new Map<string, string>()
+for (const author of blogAuthors) {
+ authorIdLookup.set(author.author_id, author.author_id)
+ if ('username' in author && author.username) {
+ authorIdLookup.set(author.username, author.author_id)
+ }
+}
+
+// Normalize any author identifier to the canonical author_id
+function toCanonicalAuthorId(identifier: string): string {
+ return authorIdLookup.get(identifier) ?? identifier
+}
+
+export async function generateStaticParams() {
+ return blogAuthors.map((author) => ({ author: author.author_id }))
+}
+
+export const revalidate = 30
+export const dynamic = 'force-static'
+
+export async function generateMetadata({
+ params: paramsPromise,
+}: {
+ params: Promise<Params>
+}): Promise<Metadata> {
+ const params = await paramsPromise
+ const author = blogAuthors.find((a) => a.author_id === params.author)
+
+ return {
+ title: author ? `Blog | ${author.author}` : 'Blog | Author',
+ description: author ? `Blog posts by ${author.author}` : 'Latest news from the Supabase team.',
+ }
+}
+
+export default async function AuthorPage({ params: paramsPromise }: { params: Promise<Params> }) {
+ const params = await paramsPromise
+ const authorId = params.author
+
+ const author = blogAuthors.find((a) => a.author_id === authorId) ?? null
+
+ // Get static posts where author field contains this author_id (normalize identifiers)
+ const staticPosts = getSortedPosts({ directory: '_blog', limit: 0 }).filter((post: any) => {
+ const postAuthors = post.author?.split(',').map((a: string) => a.trim()) || []
+ return postAuthors.some((a: string) => toCanonicalAuthorId(a) === authorId)
+ })
+
+ // Get CMS posts by this author (normalize identifiers)
+ const allCmsPosts = await getAllCMSPosts({})
+ const cmsPosts = allCmsPosts.filter((post: any) => {
+ return post.authors?.some(
+ (a: any) => toCanonicalAuthorId(a.author_id ?? a.username ?? '') === authorId
+ )
+ })
+
+ const blogs = [...(staticPosts as any[]), ...(cmsPosts as any[])].sort(
+ (a, b) => new Date(b.date).getTime() - new Date(a.date).getTime()
+ ) as unknown as PostTypes[]
+
+ return <AuthorClient author={author} authorId={authorId} blogs={blogs} />
+}
diff --git a/apps/www/components/Blog/BlogPostRenderer.tsx b/apps/www/components/Blog/BlogPostRenderer.tsx
index aa9864665f0..2b73b3a36ce 100644
--- a/apps/www/components/Blog/BlogPostRenderer.tsx
+++ b/apps/www/components/Blog/BlogPostRenderer.tsx
@@ -200,8 +200,8 @@ const BlogPostRenderer = ({
<p>{(blogMetaData as any).readingTime}</p>
</div>
{authors.length > 0 && (
- <div className="hidden lg:flex justify-between">
- <div className="flex-1 flex flex-col gap-3 pt-2 md:flex-row md:gap-0 lg:gap-3">
+ <div className="flex justify-between">
+ <div className="flex-1 flex flex-wrap gap-3 pt-2 md:gap-0 lg:gap-3">
{authors.map((author, i: number) => {
// Handle both static and CMS author image formats
const authorImageUrl =
@@ -209,13 +209,14 @@ const BlogPostRenderer = ({
? author.author_image_url
: (author.author_image_url as { url: string })?.url || ''
+ const authorId =
+ (author as any).author_id ||
+ (author as any).username ||
+ author.author.toLowerCase().replace(/\s+/g, '_')
+
return (
<div className="mr-4 w-max" key={`author-${i}-${author.author}`}>
- <Link
- href={author.author_url}
- target="_blank"
- className="cursor-pointer"
- >
+ <Link href={`/blog/authors/${authorId}`} className="cursor-pointer">
<div className="flex items-center gap-3">
{authorImageUrl && (
<div className="w-10">