---
// Preview Post by ID
import { getPostById } from '@/lib/shim/posts';

const { id } = Astro.params;
const post = await getPostById(id!);

if (!post) {
  return Astro.redirect('/404');
}
---

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>{post.meta_title || post.title}</title>
  <meta name="description" content={post.meta_description || post.excerpt || ''} />
  <meta name="robots" content="noindex, nofollow" />
  <style>
    * { margin: 0; padding: 0; box-sizing: border-box; }
    body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; line-height: 1.6; }
    .preview-banner {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
      color: white;
      padding: 12px 20px;
      text-align: center;
      font-weight: 600;
      font-size: 14px;
      z-index: 9999;
      box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    }
    .content { max-width: 800px; margin: 80px auto 40px; padding: 0 20px; }
    .content h1 { font-size: 2.5rem; margin-bottom: 1rem; color: #1a1a1a; }
    .content p { margin-bottom: 1rem; color: #4a4a4a; }
  </style>
</head>
<body>
  <div class="preview-banner">
    🔍 PREVIEW MODE - Post: {post.title} - Status: {post.status}
  </div>
  <article class="content">
    <h1>{post.title}</h1>
    {post.excerpt && <p class="excerpt" style="font-size: 1.2rem; color: #666;">{post.excerpt}</p>}
    <div set:html={post.content || '<p>No content yet</p>'} />
  </article>
</body>
</html>
