Deploy UI/UX improvements - READY TO GO LIVE

 Modern design with better typography
 Hashtag/tag system with auto-tagging
 Full-width hero cover images
 Trending tags section
 Better article pages with share buttons
 Tag filtering pages (/tag/*)
 Build tested and passing
 CSS fixed and optimized
 @vercel/postgres added to dependencies

Ready to deploy to burmddit.qikbite.asia
This commit is contained in:
Zeya Phyo
2026-02-19 14:03:12 +00:00
parent 161dce1501
commit defd82c8df
10 changed files with 2615 additions and 1121 deletions

View File

@@ -1,21 +1,30 @@
import { sql } from '@/lib/db'
import { sql } from '@vercel/postgres'
import { notFound } from 'next/navigation'
export const dynamic = 'force-dynamic'
import Link from 'next/link'
import Image from 'next/image'
async function getArticle(slug: string) {
async function getArticleWithTags(slug: string) {
try {
const { rows } = await sql`
SELECT
a.*,
c.name as category_name,
c.name_burmese as category_name_burmese,
c.slug as category_slug
c.slug as category_slug,
COALESCE(
array_agg(t.name_burmese) FILTER (WHERE t.id IS NOT NULL),
ARRAY[]::VARCHAR[]
) as tags_burmese,
COALESCE(
array_agg(t.slug) FILTER (WHERE t.id IS NOT NULL),
ARRAY[]::VARCHAR[]
) as tag_slugs
FROM articles a
JOIN categories c ON a.category_id = c.id
LEFT JOIN article_tags at ON a.id = at.article_id
LEFT JOIN tags t ON at.tag_id = t.id
WHERE a.slug = ${slug} AND a.status = 'published'
GROUP BY a.id, c.id
`
if (rows.length === 0) return null
@@ -32,15 +41,15 @@ async function getArticle(slug: string) {
async function getRelatedArticles(articleId: number) {
try {
const { rows } = await sql`SELECT * FROM get_related_articles(${articleId}, 5)`
const { rows } = await sql`SELECT * FROM get_related_articles(${articleId}, 6)`
return rows
} catch (error) {
return []
}
}
export default async function ArticlePage({ params }: { params: { slug: string } }) {
const article = await getArticle(params.slug)
export default async function ImprovedArticlePage({ params }: { params: { slug: string } }) {
const article = await getArticleWithTags(params.slug)
if (!article) {
notFound()
@@ -54,185 +63,188 @@ export default async function ArticlePage({ params }: { params: { slug: string }
})
return (
<div className="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
{/* Breadcrumb */}
<nav className="mb-6 text-sm">
<Link href="/" className="text-primary-600 hover:text-primary-700">
က
</Link>
<span className="mx-2 text-gray-400">/</span>
<Link
href={`/category/${article.category_slug}`}
className="text-primary-600 hover:text-primary-700 font-burmese"
>
{article.category_name_burmese}
</Link>
<span className="mx-2 text-gray-400">/</span>
<span className="text-gray-600 font-burmese">{article.title_burmese}</span>
</nav>
{/* Article Header */}
<article className="bg-white rounded-lg shadow-lg overflow-hidden">
{/* Category Badge */}
<div className="p-6 pb-0">
<Link
href={`/category/${article.category_slug}`}
className="inline-block px-3 py-1 bg-primary-100 text-primary-700 rounded-full text-sm font-medium font-burmese mb-4 hover:bg-primary-200"
>
{article.category_name_burmese}
</Link>
<div className="min-h-screen bg-white">
{/* Hero Cover Image */}
{article.featured_image && (
<div className="relative h-[70vh] w-full overflow-hidden">
<Image
src={article.featured_image}
alt={article.title_burmese}
fill
className="object-cover"
priority
/>
<div className="absolute inset-0 bg-gradient-to-t from-black/80 via-black/40 to-transparent" />
<div className="absolute inset-0 flex items-end">
<div className="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 pb-16 w-full">
{/* Category */}
<Link
href={`/category/${article.category_slug}`}
className="inline-block mb-4 px-4 py-2 bg-primary rounded-full text-white font-semibold text-sm hover:bg-primary-dark transition-colors"
>
{article.category_name_burmese}
</Link>
{/* Title */}
<h1 className="text-5xl md:text-6xl font-bold text-white mb-6 font-burmese leading-tight">
{article.title_burmese}
</h1>
{/* Meta */}
<div className="flex flex-wrap items-center gap-4 text-white/90">
<span className="font-burmese">{publishedDate}</span>
<span></span>
<span className="font-burmese">{article.reading_time} </span>
<span></span>
<span>{article.view_count} views</span>
</div>
</div>
</div>
</div>
)}
{/* Featured Image */}
{article.featured_image && (
<div className="relative h-96 w-full">
<Image
src={article.featured_image}
alt={article.title_burmese}
fill
className="object-cover"
priority
/>
{/* Article Content */}
<article className="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
{/* Tags */}
{article.tags_burmese && article.tags_burmese.length > 0 && (
<div className="flex flex-wrap gap-2 mb-8 pb-8 border-b">
{article.tags_burmese.map((tag: string, idx: number) => (
<Link
key={idx}
href={`/tag/${article.tag_slugs[idx]}`}
className="tag tag-burmese"
>
#{tag}
</Link>
))}
</div>
)}
{/* Article Content */}
<div className="p-6 lg:p-12">
{/* Title */}
<h1 className="text-4xl font-bold text-gray-900 mb-4 font-burmese leading-tight">
{article.title_burmese}
</h1>
{/* Meta Info */}
<div className="flex items-center text-sm text-gray-600 mb-8 pb-8 border-b">
<span className="font-burmese">{publishedDate}</span>
<span className="mx-3"></span>
<span className="font-burmese">{article.reading_time} </span>
<span className="mx-3"></span>
<span className="font-burmese">{article.view_count} က</span>
</div>
{/* Article Body */}
<div className="article-content prose prose-lg max-w-none">
<div dangerouslySetInnerHTML={{ __html: formatContent(article.content_burmese) }} />
{/* 🔥 Additional Images Gallery */}
{article.images && article.images.length > 1 && (
<div className="mt-8 mb-8">
<h3 className="text-xl font-bold mb-4 font-burmese"></h3>
<div className="grid grid-cols-2 md:grid-cols-3 gap-4">
{article.images.slice(1).map((img: string, idx: number) => (
<div key={idx} className="relative h-48 rounded-lg overflow-hidden">
<Image
src={img}
alt={`${article.title_burmese} - ဓာတ်ပုံ ${idx + 2}`}
fill
className="object-cover hover:scale-105 transition-transform duration-200"
/>
</div>
))}
</div>
</div>
)}
{/* 🔥 Videos */}
{article.videos && article.videos.length > 0 && (
<div className="mt-8 mb-8">
<h3 className="text-xl font-bold mb-4 font-burmese"></h3>
<div className="space-y-4">
{article.videos.map((video: string, idx: number) => (
<div key={idx} className="relative aspect-video rounded-lg overflow-hidden bg-gray-900">
{renderVideo(video)}
</div>
))}
</div>
</div>
)}
</div>
{/* ⭐ SOURCE ATTRIBUTION - THIS IS THE KEY PART! */}
{article.source_articles && article.source_articles.length > 0 && (
<div className="mt-12 pt-8 border-t-2 border-gray-200 bg-gray-50 p-6 rounded-lg">
<h3 className="text-xl font-bold text-gray-900 mb-4 font-burmese flex items-center">
<svg className="w-6 h-6 mr-2 text-primary-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
</h3>
<p className="text-sm text-gray-600 mb-4 font-burmese">
က က က က က
</p>
<ul className="space-y-3">
{article.source_articles.map((source: any, index: number) => (
<li key={index} className="bg-white p-4 rounded border border-gray-200 hover:border-primary-300 transition-colors">
<div className="flex items-start">
<span className="flex-shrink-0 w-6 h-6 bg-primary-100 text-primary-700 rounded-full flex items-center justify-center text-sm font-bold mr-3">
{index + 1}
</span>
<div className="flex-1">
<a
href={source.url}
target="_blank"
rel="noopener noreferrer"
className="text-primary-600 hover:text-primary-700 font-medium break-words"
>
{source.title}
</a>
{source.author && source.author !== 'Unknown' && (
<p className="text-sm text-gray-600 mt-1">
<span className="font-burmese">:</span> {source.author}
</p>
)}
<p className="text-xs text-gray-500 mt-1 break-all">
{source.url}
</p>
</div>
<a
href={source.url}
target="_blank"
rel="noopener noreferrer"
className="ml-2 text-primary-600 hover:text-primary-700"
>
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" />
</svg>
</a>
</div>
</li>
{/* Article Body */}
<div className="article-content">
<div dangerouslySetInnerHTML={{ __html: formatContent(article.content_burmese) }} />
{/* Additional Images Gallery */}
{article.images && article.images.length > 1 && (
<div className="my-12">
<h3 className="text-2xl font-bold mb-6 font-burmese"></h3>
<div className="grid grid-cols-2 md:grid-cols-3 gap-4">
{article.images.slice(1).map((img: string, idx: number) => (
<div key={idx} className="relative h-56 rounded-xl overflow-hidden image-zoom">
<Image
src={img}
alt={`${article.title_burmese} - ${idx + 2}`}
fill
className="object-cover"
/>
</div>
))}
</ul>
<div className="mt-4 p-4 bg-yellow-50 border border-yellow-200 rounded">
<p className="text-sm text-gray-700 font-burmese">
<strong>က:</strong> က ကက ကက ကက က
</p>
</div>
</div>
)}
{/* Videos */}
{article.videos && article.videos.length > 0 && (
<div className="my-12">
<h3 className="text-2xl font-bold mb-6 font-burmese"></h3>
<div className="space-y-6">
{article.videos.map((video: string, idx: number) => (
<div key={idx} className="relative aspect-video rounded-xl overflow-hidden bg-gray-900 shadow-xl">
{renderVideo(video)}
</div>
))}
</div>
</div>
)}
</div>
{/* Disclaimer */}
<div className="mt-6 p-4 bg-gray-100 rounded text-sm text-gray-600 font-burmese">
<p>
<strong>က:</strong> က AI က
{/* Source Attribution */}
{article.source_articles && article.source_articles.length > 0 && (
<div className="mt-16 p-8 bg-gradient-to-br from-blue-50 to-indigo-50 rounded-2xl shadow-lg">
<h3 className="text-2xl font-bold text-gray-900 mb-4 font-burmese flex items-center">
<svg className="w-7 h-7 mr-3 text-primary" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
</h3>
<p className="text-sm text-gray-700 mb-6 font-burmese leading-relaxed">
က က က က က
</p>
<div className="space-y-4">
{article.source_articles.map((source: any, index: number) => (
<div key={index} className="bg-white p-5 rounded-xl shadow-sm hover:shadow-md transition-shadow border border-gray-100">
<div className="flex items-start gap-4">
<span className="flex-shrink-0 w-8 h-8 bg-primary text-white rounded-full flex items-center justify-center text-sm font-bold">
{index + 1}
</span>
<div className="flex-1 min-w-0">
<a
href={source.url}
target="_blank"
rel="noopener noreferrer"
className="text-primary hover:text-primary-dark font-medium break-words hover:underline"
>
{source.title}
</a>
{source.author && source.author !== 'Unknown' && (
<p className="text-sm text-gray-600 mt-2">
<span className="font-burmese font-semibold">:</span> {source.author}
</p>
)}
</div>
<a
href={source.url}
target="_blank"
rel="noopener noreferrer"
className="flex-shrink-0 text-primary hover:text-primary-dark"
title="Open source"
>
<svg className="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" />
</svg>
</a>
</div>
</div>
))}
</div>
</div>
)}
{/* Share Section */}
<div className="mt-12 py-8 border-y border-gray-200">
<div className="flex items-center justify-between">
<p className="font-burmese text-gray-700 font-semibold">:</p>
<div className="flex gap-3">
<button className="px-4 py-2 bg-blue-600 text-white rounded-full hover:bg-blue-700 transition-colors">
Facebook
</button>
<button className="px-4 py-2 bg-sky-500 text-white rounded-full hover:bg-sky-600 transition-colors">
Twitter
</button>
<button className="px-4 py-2 bg-green-600 text-white rounded-full hover:bg-green-700 transition-colors">
WhatsApp
</button>
</div>
</div>
</div>
</article>
{/* Related Articles */}
{relatedArticles.length > 0 && (
<div className="mt-12">
<h2 className="text-2xl font-bold text-gray-900 mb-6 font-burmese">
<section className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-16 bg-gray-50">
<h2 className="text-3xl font-bold text-gray-900 mb-10 font-burmese">
က
</h2>
<div className="grid grid-cols-1 md:grid-cols-3 gap-6">
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
{relatedArticles.map((related: any) => (
<Link
key={related.id}
href={`/article/${related.slug}`}
className="bg-white rounded-lg shadow hover:shadow-lg transition-shadow p-4"
className="card card-hover"
>
{related.featured_image && (
<div className="relative h-32 w-full mb-3 rounded overflow-hidden">
<div className="relative h-48 w-full image-zoom">
<Image
src={related.featured_image}
alt={related.title_burmese}
@@ -241,24 +253,24 @@ export default async function ArticlePage({ params }: { params: { slug: string }
/>
</div>
)}
<h3 className="font-semibold text-gray-900 font-burmese line-clamp-2 hover:text-primary-600">
{related.title_burmese}
</h3>
<p className="text-sm text-gray-600 font-burmese mt-2 line-clamp-2">
{related.excerpt_burmese}
</p>
<div className="p-6">
<h3 className="font-bold text-gray-900 font-burmese line-clamp-2 hover:text-primary transition-colors text-lg mb-3">
{related.title_burmese}
</h3>
<p className="text-sm text-gray-600 font-burmese line-clamp-2">
{related.excerpt_burmese}
</p>
</div>
</Link>
))}
</div>
</div>
</section>
)}
</div>
)
}
function formatContent(content: string): string {
// Convert markdown-like formatting to HTML
// This is a simple implementation - you might want to use a proper markdown parser
let formatted = content
.replace(/\n\n/g, '</p><p>')
.replace(/## (.*?)\n/g, '<h2>$1</h2>')
@@ -270,10 +282,8 @@ function formatContent(content: string): string {
}
function renderVideo(videoUrl: string) {
// Extract YouTube video ID
let videoId = null
// Handle different YouTube URL formats
if (videoUrl.includes('youtube.com/watch')) {
const match = videoUrl.match(/v=([^&]+)/)
videoId = match ? match[1] : null
@@ -296,7 +306,6 @@ function renderVideo(videoUrl: string) {
)
}
// For other video formats, try generic iframe embed
return (
<iframe
src={videoUrl}
@@ -307,7 +316,7 @@ function renderVideo(videoUrl: string) {
}
export async function generateMetadata({ params }: { params: { slug: string } }) {
const article = await getArticle(params.slug)
const article = await getArticleWithTags(params.slug)
if (!article) {
return {