2023-10-10 07:35:11 +02:00
|
|
|
import { cloudflareImageUrl, nsMerge } from 'shared/utils.mjs'
|
2023-07-18 21:27:36 -06:00
|
|
|
// Components
|
2023-10-10 07:35:11 +02:00
|
|
|
import { MdxWrapper } from 'shared/components/wrappers/mdx.mjs'
|
|
|
|
import { Lightbox } from 'shared/components/lightbox.mjs'
|
|
|
|
import { ImageWrapper } from 'shared/components/wrappers/img.mjs'
|
|
|
|
import { TimeAgo, ns as timeagoNs } from 'shared/components/timeago/index.mjs'
|
|
|
|
import { useTranslation } from 'next-i18next'
|
2023-07-18 21:27:36 -06:00
|
|
|
import {
|
|
|
|
BaseLayout,
|
|
|
|
BaseLayoutLeft,
|
|
|
|
BaseLayoutProse,
|
|
|
|
BaseLayoutRight,
|
2023-10-10 07:35:11 +02:00
|
|
|
BaseLayoutWide,
|
2023-07-18 21:27:36 -06:00
|
|
|
} from 'shared/components/base-layout.mjs'
|
|
|
|
import {
|
|
|
|
NavLinks,
|
|
|
|
Breadcrumbs,
|
|
|
|
MainSections,
|
|
|
|
ns as navNs,
|
|
|
|
} from 'shared/components/navigation/sitenav.mjs'
|
2023-10-10 07:35:11 +02:00
|
|
|
import { Toc, ns as tocNs } from 'shared/components/mdx/toc.mjs'
|
2023-07-18 21:27:36 -06:00
|
|
|
import { PrevNext } from 'shared/components/prev-next.mjs'
|
2023-10-10 07:40:00 +02:00
|
|
|
import { Tag } from 'shared/components/tag.mjs'
|
2023-07-18 21:27:36 -06:00
|
|
|
|
2023-10-10 07:42:01 +02:00
|
|
|
export const ns = nsMerge(navNs, tocNs, timeagoNs, 'docs')
|
2023-07-18 21:27:36 -06:00
|
|
|
|
2023-10-10 07:35:11 +02:00
|
|
|
const PostMeta = ({ frontmatter, t }) => (
|
|
|
|
<div className="flex flex-row justify-between text-sm mb-1 mt-2">
|
|
|
|
<div>
|
|
|
|
<TimeAgo date={frontmatter.date} t={t} />
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
{frontmatter.designs?.map((design) => (
|
|
|
|
<Tag
|
|
|
|
href={`/showcase#filter="${design}"`}
|
|
|
|
color="primary"
|
|
|
|
hoverColor="secondary"
|
|
|
|
key={design}
|
|
|
|
>
|
|
|
|
{design}
|
|
|
|
</Tag>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
By{' '}
|
|
|
|
<a href="#maker" className="text-secondary hover:text-secondary-focus">
|
|
|
|
{frontmatter.author || frontmatter.maker || 'FIXME: No displayname'}
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
|
2023-10-10 08:53:16 +02:00
|
|
|
export const PostImage = ({ imgId, frontmatter }) => (
|
2023-10-10 07:35:11 +02:00
|
|
|
<figure>
|
|
|
|
<Lightbox>
|
|
|
|
<ImageWrapper>
|
|
|
|
<img
|
|
|
|
src={cloudflareImageUrl({ id: imgId })}
|
|
|
|
alt={frontmatter.caption}
|
|
|
|
className="shadow m-auto"
|
|
|
|
/>
|
|
|
|
</ImageWrapper>
|
|
|
|
<figcaption
|
|
|
|
className="text-center mb-8 prose m-auto text-sm italic"
|
|
|
|
dangerouslySetInnerHTML={{ __html: frontmatter.caption }}
|
|
|
|
/>
|
|
|
|
</Lightbox>
|
|
|
|
</figure>
|
|
|
|
)
|
|
|
|
|
2023-10-10 08:53:16 +02:00
|
|
|
export const PostContent = ({ mdx, dir }) => (
|
2023-10-10 07:35:11 +02:00
|
|
|
<div className="strapi prose lg:prose-lg mb-12 m-auto">
|
|
|
|
<MdxWrapper mdx={mdx} slug={`blog/${dir}`} />
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
|
2023-07-19 21:11:59 -06:00
|
|
|
/** layout for a page that displays a blog, showcase or newsletter */
|
2023-11-03 15:41:13 +01:00
|
|
|
export const PostLayout = ({ mdx, frontmatter, type, dir }) => {
|
2023-10-10 07:35:11 +02:00
|
|
|
const { t } = useTranslation(ns)
|
|
|
|
|
|
|
|
return (
|
2023-07-20 18:27:59 +02:00
|
|
|
<BaseLayout>
|
|
|
|
<BaseLayoutLeft>
|
|
|
|
<MainSections />
|
|
|
|
<NavLinks />
|
|
|
|
</BaseLayoutLeft>
|
2023-07-18 21:27:36 -06:00
|
|
|
|
2023-10-10 07:35:11 +02:00
|
|
|
<BaseLayoutWide>
|
|
|
|
<div className="w-full max-w-4xl">
|
2023-07-20 18:27:59 +02:00
|
|
|
<Breadcrumbs />
|
|
|
|
<h1 className="break-words searchme">{frontmatter.title}</h1>
|
2023-10-10 07:35:11 +02:00
|
|
|
<PostMeta frontmatter={frontmatter} t={t} />
|
2024-01-24 13:34:21 +02:00
|
|
|
{type === 'newsletter' ? null : (
|
|
|
|
<PostImage imgId={`${type}-${dir}`} frontmatter={frontmatter} />
|
|
|
|
)}
|
2023-07-20 18:27:59 +02:00
|
|
|
<div className="block xl:hidden">
|
2023-07-18 21:27:36 -06:00
|
|
|
<Toc toc={frontmatter.toc} wrap />
|
|
|
|
</div>
|
2023-07-20 18:27:59 +02:00
|
|
|
</div>
|
2023-10-10 07:35:11 +02:00
|
|
|
<div className="flex flex-row">
|
|
|
|
<BaseLayoutProse>
|
|
|
|
<article className="mb-12 max-w-7xl">
|
|
|
|
<PostContent {...{ mdx }} />
|
2023-10-10 07:42:01 +02:00
|
|
|
<PrevNext />
|
2023-10-10 07:35:11 +02:00
|
|
|
</article>
|
|
|
|
</BaseLayoutProse>
|
|
|
|
<BaseLayoutRight>
|
|
|
|
<div className="hidden xl:block xl:sticky xl:top-4">
|
|
|
|
<Toc toc={frontmatter.toc} wrap />
|
|
|
|
</div>
|
|
|
|
</BaseLayoutRight>
|
2023-07-20 18:27:59 +02:00
|
|
|
</div>
|
2023-10-10 07:35:11 +02:00
|
|
|
</BaseLayoutWide>
|
2023-07-20 18:27:59 +02:00
|
|
|
</BaseLayout>
|
2023-10-10 07:35:11 +02:00
|
|
|
)
|
|
|
|
}
|