|
| 1 | +import { PostBody } from "@/components/blog/post-body"; |
| 2 | +import { Footer } from "@/components/footer"; |
| 3 | +import { Navbar } from "@/components/navbar"; |
| 4 | +import { getPostBySlug, getPostSlugs } from "@/lib/api"; |
| 5 | +import { Container } from "@/components/container"; |
| 6 | +import { markdownToHtml } from "@/lib/markdownToHtml"; |
| 7 | +import { notFound } from "next/navigation"; |
| 8 | +import { PostHeader } from "@/components/blog/post-header"; |
| 9 | +import { Metadata } from "next"; |
| 10 | +import { Post } from "@/interfaces/post"; |
| 11 | + |
| 12 | +type ParamsType = { |
| 13 | + params: Promise<{ |
| 14 | + slug: string; |
| 15 | + }>; |
| 16 | +}; |
| 17 | + |
| 18 | +export async function generateStaticParams() { |
| 19 | + const slugs = getPostSlugs(); |
| 20 | + |
| 21 | + return slugs.map((filename: string) => ({ |
| 22 | + slug: filename.replace(/\.md$/, ""), |
| 23 | + })); |
| 24 | +} |
| 25 | + |
| 26 | +export default async function PostPage({ |
| 27 | + params, |
| 28 | +}: { |
| 29 | + params: Promise<{ slug: string }>; |
| 30 | +}) { |
| 31 | + const { slug } = await params; |
| 32 | + const post = getPostBySlug(slug) as Post; |
| 33 | + |
| 34 | + if (!post) { |
| 35 | + return notFound(); |
| 36 | + } |
| 37 | + |
| 38 | + const content = await markdownToHtml(post.content || ""); |
| 39 | + |
| 40 | + // JSON-LD for better SEO |
| 41 | + const jsonLd = { |
| 42 | + "@context": "https://schema.org", |
| 43 | + "@type": "BlogPosting", |
| 44 | + headline: post.title, |
| 45 | + image: post.coverImage ? [post.coverImage] : [], |
| 46 | + datePublished: post.date, |
| 47 | + dateModified: post.date, |
| 48 | + author: { |
| 49 | + "@type": "Person", |
| 50 | + name: post.author.name, |
| 51 | + image: post.author.picture, |
| 52 | + }, |
| 53 | + description: post.excerpt, |
| 54 | + url: `https://vaslibre.org.ve/notas/${slug}/`, |
| 55 | + }; |
| 56 | + |
| 57 | + return ( |
| 58 | + <main className="min-h-screen bg-background flex flex-col"> |
| 59 | + <Navbar /> |
| 60 | + |
| 61 | + <script |
| 62 | + type="application/ld+json" |
| 63 | + dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }} |
| 64 | + /> |
| 65 | + |
| 66 | + {/* Premium Hero Section */} |
| 67 | + <section className="relative pt-32 pb-12 md:pt-40 md:pb-20 w-full backdrop-blur-3xl overflow-hidden"> |
| 68 | + {/* Background grid pattern - Fixed Syntax */} |
| 69 | + <div className="absolute inset-0 bg-[linear-gradient(to_right,#1a1a2e_1px,transparent_1px),linear-gradient(to_bottom,#1a1a2e_1px,transparent_1px)] dark:bg-[linear-gradient(to_right,#4a4a5e_1px,transparent_1px),linear-gradient(to_bottom,#4a4a5e_1px,transparent_1px)] bg-size-[4rem_4rem] opacity-50 [mask-image:linear-gradient(to_bottom,black_40%,transparent_100%)] -z-10" /> |
| 70 | + |
| 71 | + {/* Glow effects */} |
| 72 | + <div className="absolute top-0 left-1/4 w-96 h-96 bg-primary/40 rounded-full blur-3xl animate-pulse -z-10" /> |
| 73 | + <div |
| 74 | + className="absolute bottom-0 right-1/4 w-96 h-96 bg-accent/40 rounded-full blur-3xl animate-pulse -z-10" |
| 75 | + style={{ animationDelay: "1s" }} |
| 76 | + /> |
| 77 | + |
| 78 | + <Container> |
| 79 | + <div className="max-w-4xl mx-auto text-center"> |
| 80 | + <PostHeader |
| 81 | + title={post.title} |
| 82 | + coverImage={post.coverImage} |
| 83 | + date={post.date} |
| 84 | + author={post.author} |
| 85 | + /> |
| 86 | + </div> |
| 87 | + </Container> |
| 88 | + </section> |
| 89 | + |
| 90 | + <div className="flex-1 pb-12 md:pb-16 pt-0"> |
| 91 | + <Container> |
| 92 | + <PostBody content={content} /> |
| 93 | + </Container> |
| 94 | + </div> |
| 95 | + |
| 96 | + <Footer /> |
| 97 | + </main> |
| 98 | + ); |
| 99 | +} |
| 100 | + |
| 101 | +export async function generateMetadata(props: ParamsType): Promise<Metadata> { |
| 102 | + const { slug } = await props.params; |
| 103 | + const post = getPostBySlug(slug) as Post; |
| 104 | + |
| 105 | + console.log(post.excerpt); |
| 106 | + if (!post) { |
| 107 | + return notFound(); |
| 108 | + } |
| 109 | + |
| 110 | + const title = `${post.title} - VaSLibre`; |
| 111 | + const url = `https://vaslibre.org.ve/notas/${slug}/`; |
| 112 | + |
| 113 | + return { |
| 114 | + title, |
| 115 | + description: post.excerpt, |
| 116 | + openGraph: { |
| 117 | + title, |
| 118 | + description: post.excerpt, |
| 119 | + images: [post.ogImage.url], |
| 120 | + url, |
| 121 | + }, |
| 122 | + |
| 123 | + alternates: { |
| 124 | + canonical: url, |
| 125 | + }, |
| 126 | + }; |
| 127 | +} |
0 commit comments