import React, {ReactNode} from 'react' import Link from 'next/link' import {Container} from '@/components/common/Container' import {Prose} from '@/components/ui/Prose' import {Views} from '@/components/ui/Views' import {ArrowDownIcon} from '@/components/icons/ArrowDownIcon' import ArticleNav from '@/components/ui/ArticleNav' import {Comments} from '@/components/ui/Comments' import {Subscribe} from '@/components/ui/Subscribe' import {getAllArticles} from '@/lib/getAllArticles' import {getComments} from '@/lib/getComments' import {format} from 'date-fns' type ArticleLayout = { title: string date: string description: string slug: string children?: ReactNode } const gradients = [ 'bg-gradient-to-r from-blue-500 to-blue-600', 'bg-[conic-gradient(at_left,_var(--tw-gradient-stops))] from-rose-500 to-indigo-700', 'bg-[conic-gradient(at_left,_var(--tw-gradient-stops))] from-sky-400 to-blue-800', 'bg-gradient-to-r from-orange-400 to-rose-400', 'bg-gradient-to-r from-sky-400 to-blue-500' ] type Article = { slug: string authors: string title: string date: string description: string } function findAdjacentArticles(articles: Article[], slug: string) { let prev, next if (articles) { const index = articles.findIndex(article => article.slug === slug) prev = index > 0 ? articles[index - 1] : null next = index < articles.length - 1 ? articles[index + 1] : null } return {prev, next} } export async function ArticleLayout({ title, date, slug, children }: ArticleLayout) { const comments = await getComments(slug) const articles = await getAllArticles(false) const {prev, next} = findAdjacentArticles(articles, slug) return (

{title}

{children}
) }