2023-02-17 22:33:59 +00:00
|
|
|
import React, {ReactNode} from 'react'
|
2023-02-23 21:22:50 +00:00
|
|
|
import Link from 'next/link'
|
2023-05-28 20:15:39 +00:00
|
|
|
import {Container} from '@/components/common/Container'
|
2023-02-14 21:40:16 +00:00
|
|
|
import {Prose} from '@/components/ui/Prose'
|
|
|
|
import {Views} from '@/components/ui/Views'
|
2023-02-17 22:33:59 +00:00
|
|
|
import {ArrowDownIcon} from '@/components/icons/ArrowDownIcon'
|
|
|
|
import {formatDate} from '@/lib/formatDate'
|
2024-10-01 21:00:02 +00:00
|
|
|
import ArticleNav from '@/components/ui/ArticleNav'
|
2022-12-06 12:54:34 +00:00
|
|
|
|
2023-01-14 23:18:52 +00:00
|
|
|
type ArticleLayout = {
|
|
|
|
title: string
|
|
|
|
date: string
|
2023-07-29 22:40:36 +00:00
|
|
|
description: string
|
2023-01-17 21:24:16 +00:00
|
|
|
slug: string
|
2023-07-29 22:40:36 +00:00
|
|
|
children?: ReactNode
|
2023-01-14 23:18:52 +00:00
|
|
|
}
|
|
|
|
|
2023-07-29 22:40:36 +00:00
|
|
|
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'
|
|
|
|
]
|
|
|
|
|
2022-12-06 12:54:34 +00:00
|
|
|
export function ArticleLayout({
|
2023-01-14 19:31:05 +00:00
|
|
|
title,
|
2023-07-29 22:40:36 +00:00
|
|
|
date,
|
|
|
|
slug,
|
|
|
|
children,
|
2023-01-14 23:18:52 +00:00
|
|
|
}: ArticleLayout) {
|
2022-12-06 12:54:34 +00:00
|
|
|
|
|
|
|
return (
|
2023-07-29 22:40:36 +00:00
|
|
|
<Container className="mt-16 lg:mt-32">
|
|
|
|
<div className="xl:relative">
|
|
|
|
<div className="mx-auto max-w-2xl">
|
|
|
|
<Link href="/writing">
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
aria-label="Go back to articles"
|
|
|
|
className="group mb-8 flex h-10 w-10 items-center justify-center rounded-full bg-white shadow-md shadow-zinc-800/5 ring-1 ring-zinc-900/5 transition dark:border dark:border-zinc-700/50 dark:bg-zinc-800 dark:ring-0 dark:ring-white/10 dark:hover:border-zinc-700 dark:hover:ring-white/20 lg:absolute lg:-left-5 lg:mb-0 lg:-mt-2 xl:-top-1.5 xl:left-0 xl:mt-0"
|
|
|
|
>
|
|
|
|
<ArrowDownIcon
|
|
|
|
className="h-4 w-4 stroke-zinc-500 transition group-hover:stroke-zinc-700 dark:stroke-zinc-500 dark:group-hover:stroke-zinc-400 rotate-90"/>
|
|
|
|
</button>
|
|
|
|
</Link>
|
|
|
|
<article>
|
|
|
|
<header className="flex flex-col">
|
2023-08-06 21:23:21 +00:00
|
|
|
<h1 className={`mt-6 text-4xl font-bold tracking-tight sm:text-5xl bg-clip-text pb-1 dark:text-transparent ${gradients[Math.floor(gradients.length * Math.random())]}`}>
|
2023-07-29 22:40:36 +00:00
|
|
|
{title}
|
|
|
|
</h1>
|
|
|
|
<p className="order-first text-base text-zinc-500 dark:text-zinc-400">
|
|
|
|
<time dateTime={date}>
|
|
|
|
<span>{formatDate(date)}</span>
|
|
|
|
</time>
|
|
|
|
<Views slug={slug} shouldUpdateViews={true}/>
|
|
|
|
</p>
|
|
|
|
</header>
|
2023-08-07 13:58:08 +00:00
|
|
|
<Prose className="mt-8" data-mdx-content>{children}</Prose>
|
2023-07-29 22:40:36 +00:00
|
|
|
</article>
|
2024-10-01 21:00:02 +00:00
|
|
|
<ArticleNav slug={slug}/>
|
2022-12-06 12:54:34 +00:00
|
|
|
</div>
|
2023-07-29 22:40:36 +00:00
|
|
|
</div>
|
|
|
|
</Container>
|
2022-12-06 12:54:34 +00:00
|
|
|
)
|
|
|
|
}
|