|
| 1 | +import { notFound } from 'next/navigation' |
| 2 | +import { Badge } from "@/components/ui/badge" |
| 3 | +import Link from 'next/link' |
| 4 | +import { ArrowLeft } from 'lucide-react' |
| 5 | + |
| 6 | +interface Post { |
| 7 | + slug: string |
| 8 | + title: string |
| 9 | + date: string |
| 10 | + content: string |
| 11 | + tags: string[] |
| 12 | +} |
| 13 | + |
| 14 | +const posts: Record<string, Post> = { |
| 15 | + 'release-v2': { |
| 16 | + slug: 'release-v2', |
| 17 | + title: 'Release of Tailwind Nextjs Starter Blog v2.0', |
| 18 | + date: 'August 5, 2023', |
| 19 | + content: 'Release of Tailwind Nextjs Starter Blog template v2.0, refactored with Nextjs App directory and React Server Components setup.', |
| 20 | + tags: ['NEXT-JS', 'TAILWIND', 'GUIDE', 'FEATURE'], |
| 21 | + }, |
| 22 | + 'new-features-v1': { |
| 23 | + slug: 'new-features-v1', |
| 24 | + title: 'New features in v1', |
| 25 | + date: 'August 7, 2021', |
| 26 | + content: 'An overview of the new features released in v1 - code block copy, multiple authors, frontmatter layout and more', |
| 27 | + tags: ['NEXT-JS', 'TAILWIND', 'GUIDE'], |
| 28 | + }, |
| 29 | + 'multi-part-posts': { |
| 30 | + slug: 'multi-part-posts', |
| 31 | + title: 'Introducing Multi-part Posts with Nested Routing', |
| 32 | + date: 'May 2, 2021', |
| 33 | + content: 'The blog template supports posts in nested sub-folders. This can be used to group posts of similar content e.g. a multi-part course. This post is itself an example of a nested route!', |
| 34 | + tags: ['FEATURE', 'NEXT-JS'], |
| 35 | + }, |
| 36 | + 'seo-optimization-guide': { |
| 37 | + slug: 'seo-optimization-guide', |
| 38 | + title: 'SEO Optimization for Next.js Blogs', |
| 39 | + date: 'March 15, 2023', |
| 40 | + content: 'A step-by-step guide to optimizing your Next.js blog for search engines using dynamic metadata, Open Graph, and structured data.', |
| 41 | + tags: ['NEXT-JS', 'SEO', 'GUIDE'], |
| 42 | + }, |
| 43 | + 'tailwind-best-practices': { |
| 44 | + slug: 'tailwind-best-practices', |
| 45 | + title: 'Best Practices for Tailwind CSS', |
| 46 | + date: 'July 10, 2022', |
| 47 | + content: 'Learn how to use Tailwind CSS effectively with reusable components, themes, and responsive design techniques.', |
| 48 | + tags: ['TAILWIND', 'CSS', 'GUIDE'], |
| 49 | + }, |
| 50 | + 'performance-improvements': { |
| 51 | + slug: 'performance-improvements', |
| 52 | + title: 'Boosting Performance in Next.js Apps', |
| 53 | + date: 'November 22, 2023', |
| 54 | + content: 'Explore techniques to enhance the performance of your Next.js applications with lazy loading, dynamic imports, and more.', |
| 55 | + tags: ['NEXT-JS', 'PERFORMANCE', 'FEATURE'], |
| 56 | + }, |
| 57 | + 'markdown-integration': { |
| 58 | + slug: 'markdown-integration', |
| 59 | + title: 'Markdown Integration in Next.js', |
| 60 | + date: 'January 5, 2022', |
| 61 | + content: 'Understand how to use markdown files with Next.js to create a seamless blogging experience.', |
| 62 | + tags: ['NEXT-JS', 'MARKDOWN', 'GUIDE'], |
| 63 | + }, |
| 64 | + 'custom-themes': { |
| 65 | + slug: 'custom-themes', |
| 66 | + title: 'Creating Custom Themes with Tailwind CSS', |
| 67 | + date: 'February 18, 2023', |
| 68 | + content: 'Learn how to build and apply custom themes using Tailwind CSS for consistent branding across your web apps.', |
| 69 | + tags: ['TAILWIND', 'CUSTOMIZATION', 'GUIDE'], |
| 70 | + }, |
| 71 | + 'dynamic-routing': { |
| 72 | + slug: 'dynamic-routing', |
| 73 | + title: 'Understanding Dynamic Routing in Next.js', |
| 74 | + date: 'June 20, 2021', |
| 75 | + content: 'A comprehensive explanation of dynamic routing and how to implement it in Next.js projects.', |
| 76 | + tags: ['NEXT-JS', 'ROUTING', 'FEATURE'], |
| 77 | + }, |
| 78 | + 'accessibility-tips': { |
| 79 | + slug: 'accessibility-tips', |
| 80 | + title: 'Web Accessibility Tips for Tailwind CSS Users', |
| 81 | + date: 'October 10, 2022', |
| 82 | + content: 'Discover how to make your Tailwind CSS-based websites more accessible to all users.', |
| 83 | + tags: ['TAILWIND', 'ACCESSIBILITY', 'GUIDE'], |
| 84 | + }, |
| 85 | +}; |
| 86 | + |
| 87 | + |
| 88 | +export default function BlogPost({ params }: { params: { slug: string } }) { |
| 89 | + const post = posts[params.slug] |
| 90 | + |
| 91 | + if (!post) { |
| 92 | + notFound() |
| 93 | + } |
| 94 | + |
| 95 | + return ( |
| 96 | + <article className="max-w-2xl mx-auto"> |
| 97 | + <Link href="/blog" className="inline-flex items-center text-sm text-muted-foreground hover:text-primary mb-8"> |
| 98 | + <ArrowLeft className="mr-2 h-4 w-4" /> |
| 99 | + Back to all posts |
| 100 | + </Link> |
| 101 | + <div className="space-y-4"> |
| 102 | + <div className="text-sm text-muted-foreground">{post.date}</div> |
| 103 | + <h1 className="text-4xl font-bold">{post.title}</h1> |
| 104 | + <div className="flex flex-wrap gap-2"> |
| 105 | + {post.tags.map((tag) => ( |
| 106 | + <Badge key={tag} variant="secondary"> |
| 107 | + {tag} |
| 108 | + </Badge> |
| 109 | + ))} |
| 110 | + </div> |
| 111 | + <div className="prose dark:prose-invert mt-8"> |
| 112 | + {post.content} |
| 113 | + </div> |
| 114 | + </div> |
| 115 | + </article> |
| 116 | + ) |
| 117 | +} |
| 118 | + |
0 commit comments