Archived
Refactor to static markdown (remove Supabase backend) + self-host build
build-and-publish / build (push) Successful in 11s
build-and-publish / build (push) Successful in 11s
Posts now read from data/posts/*.md via gray-matter + remark; authors derived from posts. Removes admin dashboard, comments, subscriptions, and all Supabase usage. Adds Dockerfile (Next.js standalone) + Gitea Actions CI. output: standalone. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This commit is contained in:
@@ -1,105 +1,27 @@
|
||||
'use client';
|
||||
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { createClient } from '@/utils/supabase/client';
|
||||
|
||||
const supabase = createClient();
|
||||
import React from 'react';
|
||||
import { PostMetadata } from '@/types';
|
||||
|
||||
interface AuthorProfile {
|
||||
name: string;
|
||||
bio: string;
|
||||
x_link?: string;
|
||||
fb_link?: string;
|
||||
insta_link?: string;
|
||||
pfp_link?: string;
|
||||
}
|
||||
|
||||
interface AuthorProfileProps {
|
||||
author: string;
|
||||
posts: PostMetadata[];
|
||||
}
|
||||
|
||||
export default function AuthorProfile({ author, posts }: AuthorProfileProps) {
|
||||
const [authorProfile, setAuthorProfile] = useState<AuthorProfile | null>(null);
|
||||
|
||||
const fetchAuthorProfile = async () => {
|
||||
const { data, error } = await supabase
|
||||
.from('authors')
|
||||
.select('name, bio, x_link, fb_link, insta_link, pfp_link')
|
||||
.eq('name', author)
|
||||
.single();
|
||||
|
||||
if (error) {
|
||||
console.warn('No author profile found for:', author, '→', error.message);
|
||||
}
|
||||
|
||||
if (data) {
|
||||
setAuthorProfile(data);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
fetchAuthorProfile();
|
||||
}, [author]);
|
||||
|
||||
// Static author profile. No bio/social data is available in the markdown
|
||||
// source, so we render the author's name and a placeholder avatar only.
|
||||
export default function AuthorProfile({ author }: AuthorProfileProps) {
|
||||
return (
|
||||
<div className="mb-12 flex flex-col md:flex-row items-start md:items-center gap-6">
|
||||
{/* Profile Picture */}
|
||||
{authorProfile?.pfp_link ? (
|
||||
<img
|
||||
src={authorProfile.pfp_link}
|
||||
alt={`${authorProfile.name}'s profile picture`}
|
||||
className="w-24 h-24 rounded-full object-cover shadow-md"
|
||||
/>
|
||||
) : (
|
||||
<div className="w-24 h-24 rounded-full bg-gray-200 flex items-center justify-center text-xl font-bold text-gray-500">
|
||||
?
|
||||
</div>
|
||||
)}
|
||||
{/* Placeholder avatar */}
|
||||
<div className="w-24 h-24 rounded-full bg-gray-200 flex items-center justify-center text-2xl font-bold text-gray-500">
|
||||
{author.charAt(0).toUpperCase()}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
{/* Author Name */}
|
||||
<h1 className="text-3xl md:text-4xl font-bold mb-2">
|
||||
{authorProfile?.name || author}
|
||||
{author}
|
||||
</h1>
|
||||
|
||||
{/* Author Bio */}
|
||||
{authorProfile?.bio && (
|
||||
<p className="text-primary-600 mb-2">{authorProfile.bio}</p>
|
||||
)}
|
||||
|
||||
{/* Social Links */}
|
||||
<div className="flex gap-4 mt-2">
|
||||
{authorProfile?.x_link && (
|
||||
<a
|
||||
href={authorProfile.x_link}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<img src="/icons/x.svg" alt="X (Twitter)" className="w-5 h-5" />
|
||||
</a>
|
||||
)}
|
||||
{authorProfile?.fb_link && (
|
||||
<a
|
||||
href={authorProfile.fb_link}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<img src="/icons/facebook.svg" alt="Facebook" className="w-5 h-5" />
|
||||
</a>
|
||||
)}
|
||||
{authorProfile?.insta_link && (
|
||||
<a
|
||||
href={authorProfile.insta_link}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<img src="/icons/instagram.svg" alt="Instagram" className="w-5 h-5" />
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import React from 'react';
|
||||
import PostCard from '@/components/PostCard';
|
||||
import { getPostsByAuthor } from '@/lib/posts';
|
||||
import { getAllAuthors } from '@/lib/authors';
|
||||
import { PostMetadata } from '@/types';
|
||||
import { generateMetadata as createMetadata } from '@/components/Metadata';
|
||||
import type { Metadata } from 'next';
|
||||
@@ -10,13 +11,19 @@ interface PageProps {
|
||||
params: Promise<{ author: string }>;
|
||||
}
|
||||
|
||||
export const dynamic = 'force-dynamic';
|
||||
export async function generateStaticParams() {
|
||||
const authors = await getAllAuthors();
|
||||
return authors.map((author) => ({
|
||||
author: author.slug,
|
||||
}));
|
||||
}
|
||||
|
||||
export async function generateMetadata({ params }: PageProps): Promise<Metadata> {
|
||||
const { author } = await params;
|
||||
const decodedAuthor = decodeURIComponent(author);
|
||||
return createMetadata({
|
||||
title: `${author} | Author`,
|
||||
description: `Posts authored by ${author} on Confessions of Grace.`,
|
||||
title: `${decodedAuthor} | Author`,
|
||||
description: `Posts authored by ${decodedAuthor} on Confessions of Grace.`,
|
||||
url: `https://confessionsofgrace.com/authors/${author}`,
|
||||
type: 'website'
|
||||
});
|
||||
@@ -28,15 +35,16 @@ async function getPostsByAuthorData(author: string): Promise<PostMetadata[]> {
|
||||
|
||||
export default async function AuthorPage({ params }: PageProps) {
|
||||
const { author } = await params;
|
||||
const posts = await getPostsByAuthorData(author);
|
||||
const decodedAuthor = decodeURIComponent(author);
|
||||
const posts = await getPostsByAuthorData(decodedAuthor);
|
||||
|
||||
return (
|
||||
<div className="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<AuthorProfile author={author} posts={posts} />
|
||||
<AuthorProfile author={decodedAuthor} posts={posts} />
|
||||
|
||||
{/* Posts */}
|
||||
<p className="text-lg text-primary-600 mb-6">
|
||||
{posts.length} {posts.length === 1 ? 'post' : 'posts'} authored by "{author}"
|
||||
{posts.length} {posts.length === 1 ? 'post' : 'posts'} authored by "{decodedAuthor}"
|
||||
</p>
|
||||
|
||||
{posts.length > 0 ? (
|
||||
@@ -52,4 +60,4 @@ export default async function AuthorPage({ params }: PageProps) {
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+9
-44
@@ -1,21 +1,9 @@
|
||||
export const dynamic = 'force-dynamic';
|
||||
|
||||
import React from 'react';
|
||||
import Link from 'next/link';
|
||||
import Image from 'next/image';
|
||||
import { createClient } from '@/utils/supabase/server';
|
||||
import { getAllAuthors } from '@/lib/authors';
|
||||
import { generateMetadata as createMetadata } from '@/components/Metadata';
|
||||
import type { Metadata } from 'next';
|
||||
|
||||
interface AuthorProfile {
|
||||
name: string;
|
||||
bio: string;
|
||||
x_link?: string;
|
||||
fb_link?: string;
|
||||
insta_link?: string;
|
||||
pfp_link?: string;
|
||||
}
|
||||
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
return createMetadata({
|
||||
title: 'Authors',
|
||||
@@ -25,27 +13,8 @@ export async function generateMetadata(): Promise<Metadata> {
|
||||
});
|
||||
}
|
||||
|
||||
async function getAuthors(): Promise<AuthorProfile[]> {
|
||||
try {
|
||||
const supabase = await createClient();
|
||||
const { data: authorsData, error } = await supabase
|
||||
.from('authors')
|
||||
.select('name, bio, x_link, fb_link, insta_link, pfp_link');
|
||||
|
||||
if (error || !authorsData) {
|
||||
console.error('Error fetching authors:', error);
|
||||
return [];
|
||||
}
|
||||
|
||||
return authorsData;
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch authors during build:', error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
export default async function AuthorsPage() {
|
||||
const authors = await getAuthors();
|
||||
const authors = await getAllAuthors();
|
||||
|
||||
return (
|
||||
<div className="max-w-5xl mx-auto px-4">
|
||||
@@ -55,20 +24,16 @@ export default async function AuthorsPage() {
|
||||
{authors.map((author) => (
|
||||
<Link
|
||||
key={author.name}
|
||||
href={`/authors/${author.name}`}
|
||||
href={`/authors/${encodeURIComponent(author.slug)}`}
|
||||
className="bg-white rounded-lg shadow-md p-5 flex flex-col items-center hover:shadow-lg transition-shadow"
|
||||
>
|
||||
<div className="w-24 h-24 mb-4 relative">
|
||||
<Image
|
||||
src={author.pfp_link || '/images/authors/default.jpg'}
|
||||
alt={`${author.name}'s profile`}
|
||||
fill
|
||||
className="rounded-full object-cover"
|
||||
sizes="96px"
|
||||
/>
|
||||
<div className="w-24 h-24 mb-4 rounded-full bg-gray-200 flex items-center justify-center text-2xl font-bold text-gray-500">
|
||||
{author.name.charAt(0).toUpperCase()}
|
||||
</div>
|
||||
<h2 className="text-lg font-semibold">{author.name}</h2>
|
||||
{/* You can include bio or social icons here */}
|
||||
<p className="text-sm text-primary-500 mt-1">
|
||||
{author.postCount} {author.postCount === 1 ? 'post' : 'posts'}
|
||||
</p>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
@@ -80,4 +45,4 @@ export default async function AuthorsPage() {
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user