Files
burmddit/frontend/app/page.tsx
Min Zeya Phyo 98af1c7cec Adapt for self-hosted deployment on Coolify
- Replace @vercel/postgres with standard pg library
- Add Dockerfile for Next.js standalone build
- Add tsconfig.json, postcss.config.js
- Fix globals.css undefined tailwind utilities
- Force dynamic rendering for DB-dependent pages
- Add .dockerignore
2026-02-19 16:51:31 +08:00

127 lines
4.6 KiB
TypeScript

import { sql } from '@/lib/db'
import ArticleCard from '@/components/ArticleCard'
export const dynamic = 'force-dynamic'
import TrendingSection from '@/components/TrendingSection'
import CategoryNav from '@/components/CategoryNav'
async function getRecentArticles() {
try {
const { rows } = await sql`
SELECT * FROM published_articles
ORDER BY published_at DESC
LIMIT 20
`
return rows
} catch (error) {
console.error('Error fetching articles:', error)
return []
}
}
async function getTrendingArticles() {
try {
const { rows } = await sql`SELECT * FROM get_trending_articles(10)`
return rows
} catch (error) {
console.error('Error fetching trending:', error)
return []
}
}
export default async function Home() {
const [articles, trending] = await Promise.all([
getRecentArticles(),
getTrendingArticles()
])
return (
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
{/* Hero Section */}
<section className="mb-12 text-center">
<h1 className="text-5xl font-bold text-gray-900 mb-4 font-burmese">
Burmddit
</h1>
<p className="text-xl text-gray-600 font-burmese">
AI ကက
</p>
<p className="text-lg text-gray-500 mt-2">
Daily AI News, Tutorials & Tips in Burmese
</p>
</section>
{/* Category Navigation */}
<CategoryNav />
{/* Main Content Grid */}
<div className="grid grid-cols-1 lg:grid-cols-3 gap-8 mt-8">
{/* Main Articles (Left 2/3) */}
<div className="lg:col-span-2">
<h2 className="text-2xl font-bold text-gray-900 mb-6 font-burmese">
က
</h2>
{articles.length === 0 ? (
<div className="text-center py-12 bg-white rounded-lg shadow">
<p className="text-gray-500 font-burmese">
က က
</p>
</div>
) : (
<div className="space-y-6">
{articles.map((article) => (
<ArticleCard key={article.id} article={article} />
))}
</div>
)}
</div>
{/* Sidebar (Right 1/3) */}
<aside className="space-y-8">
{/* Trending Articles */}
<TrendingSection articles={trending} />
{/* Categories Card */}
<div className="bg-white rounded-lg shadow p-6">
<h3 className="text-lg font-bold text-gray-900 mb-4 font-burmese">
</h3>
<ul className="space-y-2">
<li>
<a href="/category/ai-news" className="text-primary-600 hover:text-primary-700 font-burmese">
AI
</a>
</li>
<li>
<a href="/category/tutorials" className="text-primary-600 hover:text-primary-700 font-burmese">
</a>
</li>
<li>
<a href="/category/tips-tricks" className="text-primary-600 hover:text-primary-700 font-burmese">
ကက
</a>
</li>
<li>
<a href="/category/upcoming" className="text-primary-600 hover:text-primary-700 font-burmese">
</a>
</li>
</ul>
</div>
{/* About Card */}
<div className="bg-gradient-to-br from-primary-50 to-primary-100 rounded-lg shadow p-6">
<h3 className="text-lg font-bold text-gray-900 mb-3 font-burmese">
Burmddit က
</h3>
<p className="text-gray-700 text-sm leading-relaxed font-burmese">
Burmddit AI က က ကကက က
</p>
</div>
</aside>
</div>
</div>
)
}