Files
dealplustech-astroreal/src/pages/บทความ/index.astro
Kunthawat Greethong ef4b0f2e89 refactor: move blog from EmDash to Astro content collections
EmDash CMS integration is being removed. The blog content is
moved to native Astro content collections (markdown files in
src/content/blog/) which works with the static output config.

Changes:
- Remove EmDash from astro.config.mjs (revert to static output)
- Remove emdash packages from package.json/package-lock.json
- Remove seed/seed.json (was EmDash-only)
- Remove src/live.config.ts (EmDash Astro loader)
- Add src/content.config.ts (Astro content collection for blog)
- Move 3 blog posts to src/content/blog/*.md
- Update src/pages/index.astro to use getCollection('blog')
- Update src/pages/บทความ/[slug].astro to use render() from astro:content
  (Astro 6 API: render(article), not article.render())
- Update src/pages/บทความ/index.astro (blog list)
- Add .hermes/ to .gitignore

Verified:
- npm run build: 35 pages, complete in 2.50s
- / , /aeroflex, /about-us, /บทความ, /บทความ/welcome-post: all 200
2026-06-03 14:02:41 +07:00

71 lines
4.4 KiB
Plaintext

---
import BaseLayout from '@/layouts/BaseLayout.astro';
import { getCollection } from 'astro:content';
const articles = (await getCollection('blog')).sort(
(a, b) => b.data.published_at.getTime() - a.data.published_at.getTime()
);
---
<BaseLayout title="บทความทั้งหมด - ดีล พลัส เทค" description="รวมบทความและความรู้เกี่ยวกับระบบน้ำ ท่อ และอุปกรณ์ต่างๆ จากดีล พลัส เทค">
<main class="bg-white min-h-screen">
<!-- Hero -->
<section class="bg-gradient-to-br from-primary-800 via-primary-700 to-primary-900 text-white py-16 lg:py-24">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="max-w-3xl">
<span class="inline-block px-4 py-1.5 bg-white/20 text-white rounded-full text-sm font-medium mb-4">บทความ</span>
<h1 class="text-3xl sm:text-4xl lg:text-5xl font-bold mb-4">บทความทั้งหมด</h1>
<p class="text-lg sm:text-xl text-white/80 leading-relaxed">ความรู้และข้อมูลที่เป็นประโยชน์เกี่ยวกับระบบน้ำ ท่อ อุปกรณ์วาล์ว และอื่นๆ</p>
</div>
</div>
</section>
<!-- Articles Grid -->
<section class="py-16 lg:py-24">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
{articles.length > 0 ? (
<div class="grid md:grid-cols-2 lg:grid-cols-3 gap-8">
{articles.map(article => (
<a href={`/${encodeURI('บทความ')}/${encodeURIComponent(article.id)}`} class="group block bg-white rounded-3xl overflow-hidden border border-slate-100 hover:border-primary-200 hover:shadow-xl transition-all duration-300">
<div class="aspect-[16/9] bg-slate-100 overflow-hidden">
{article.data.featured_image ? (
<img src={article.data.featured_image} alt={article.data.title} class="w-full h-full object-cover group-hover:scale-105 transition-transform duration-500" loading="lazy" />
) : (
<div class="w-full h-full flex items-center justify-center text-slate-300">
<svg class="w-16 h-16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"/>
</svg>
</div>
)}
</div>
<div class="p-6">
<div class="flex items-center gap-3 text-sm text-slate-500 mb-3">
<time datetime={article.data.published_at.toISOString().slice(0, 10)}>
{article.data.published_at.toLocaleDateString('th-TH', { year: 'numeric', month: 'long', day: 'numeric' })}
</time>
{article.data.tags?.[0] && (
<span class="px-2.5 py-0.5 bg-primary-50 text-primary-600 rounded-full text-xs font-medium">{article.data.tags[0]}</span>
)}
</div>
<h2 class="text-lg font-bold text-slate-900 group-hover:text-primary-600 transition-colors mb-2 line-clamp-2">{article.data.title}</h2>
<p class="text-sm text-slate-600 line-clamp-2">{article.data.excerpt}</p>
</div>
</a>
))}
</div>
) : (
<div class="text-center py-16">
<div class="text-slate-300 mb-4">
<svg class="w-16 h-16 mx-auto" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M19 20H5a2 2 0 01-2-2V6a2 2 0 012-2h10a2 2 0 012 2v1m2 13a2 2 0 01-2-2V7m2 13a2 2 0 002-2V9a2 2 0 00-2-2h-2m-4-3H9M7 16h6M7 8h6v4H7V8z"/>
</svg>
</div>
<p class="text-xl text-slate-400 mb-2">ยังไม่มีบทความ</p>
<p class="text-slate-400">กลับมาตรวจสอบอีกครั้งในภายหลัง</p>
</div>
)}
</div>
</section>
</main>
</BaseLayout>