ဓာတ်ပုံများ
ဗီဒီယိုများ
မူရင်းသတင်းရင်းမြစ်များ
ဤဆောင်းပါးကို အောက်ပါမူရင်းသတင်းများမှ စုစည်း၍ မြန်မာဘာသာသို့ ပြန်ဆိုထားခြင်း ဖြစ်ပါသည်။ အားလုံးသော အကြွေးအရ မူရင်းစာရေးသူများနှင့် ထုတ်ပြန်သူများကို သက်ဆိုင်ပါသည်။
စာရေးသူ: {source.author}
)}မျှဝေပါ:
import { sql } from '@/lib/db' export const dynamic = "force-dynamic" import { notFound } from 'next/navigation' import Link from 'next/link' import Image from 'next/image' import AdminButton from '@/components/AdminButton' 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, 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 // Increment view count await sql`SELECT increment_view_count(${slug})` return rows[0] } catch (error) { console.error('Error fetching article:', error) return null } } async function getRelatedArticles(articleId: number) { try { const { rows } = await sql`SELECT * FROM get_related_articles(${articleId}, 6)` return rows } catch (error) { return [] } } export default async function ImprovedArticlePage({ params }: { params: { slug: string } }) { const article = await getArticleWithTags(params.slug) if (!article) { notFound() } const relatedArticles = await getRelatedArticles(article.id) const publishedDate = new Date(article.published_at).toLocaleDateString('my-MM', { year: 'numeric', month: 'long', day: 'numeric' }) return (
ဤဆောင်းပါးကို အောက်ပါမူရင်းသတင်းများမှ စုစည်း၍ မြန်မာဘာသာသို့ ပြန်ဆိုထားခြင်း ဖြစ်ပါသည်။ အားလုံးသော အကြွေးအရ မူရင်းစာရေးသူများနှင့် ထုတ်ပြန်သူများကို သက်ဆိုင်ပါသည်။
စာရေးသူ: {source.author}
)}မျှဝေပါ:
{related.excerpt_burmese}
') .replace(/## (.*?)\n/g, '
${formatted}
` } function renderVideo(videoUrl: string) { let videoId = null if (videoUrl.includes('youtube.com/watch')) { const match = videoUrl.match(/v=([^&]+)/) videoId = match ? match[1] : null } else if (videoUrl.includes('youtu.be/')) { const match = videoUrl.match(/youtu\.be\/([^?]+)/) videoId = match ? match[1] : null } else if (videoUrl.includes('youtube.com/embed/')) { const match = videoUrl.match(/embed\/([^?]+)/) videoId = match ? match[1] : null } if (videoId) { return ( ) } return ( ) } export async function generateMetadata({ params }: { params: { slug: string } }) { const article = await getArticleWithTags(params.slug) if (!article) { return { title: 'Article Not Found', } } return { title: `${article.title_burmese} - Burmddit`, description: article.excerpt_burmese, openGraph: { title: article.title_burmese, description: article.excerpt_burmese, images: article.featured_image ? [article.featured_image] : [], }, } }