import React from "react"; import { notFound } from "next/navigation"; import { format } from "date-fns"; import { Avatar, Badge, Button, Text } from "@/components/retroui"; import { Metadata } from "next"; import Image from "next/image"; import Link from "next/link"; import { RichText } from "@payloadcms/richtext-lexical/react"; import { JSXConverters } from "@/components/RichTextConverter"; interface IProps { params: { slug: string[] }; } type Post = { id: number, title: string, slug: string, publishedAt: string, content: any, excerpt: string, tags: { name: string, slug: string }[], featuredImage: { url: string, alt: string }, } async function getBlogParams({ params }: IProps) { const res = await fetch(`https://cms.retroui.dev/api/posts/slug/${params.slug}`, { method: 'GET', credentials: 'include', next: { revalidate: 60, }, }) const post = await res.json() return post; } export async function generateMetadata({ params }: IProps): Promise { const blog: Post = await getBlogParams({ params }); if (!blog) { return { title: "Not Found | Retro UI", }; } return { title: `${blog.title} | RetroUI Blogs`, description: blog.excerpt, alternates: { canonical: `https://www.retroui.dev/blogs/${blog.slug}`, }, openGraph: { type: "article", images: blog.featuredImage.url, title: `${blog.title} | RetroUI Blogs`, publishedTime: blog.publishedAt, authors: ["Arif Hossain"], }, }; } export default async function page({ params }: IProps) { const blog: Post | null = await getBlogParams({ params }); if (!blog) { return notFound(); } return (
{format(new Date(blog.publishedAt), "dd, MMMM yyyy")} |
{blog.tags.map((tag) => ( {tag.name} ))}
{blog.title} {blog.excerpt} {blog.featuredImage.alt}
AH
Arif Hossain @ariflogs

); }