-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
destructure and optimize home layout
- Loading branch information
PxlSyl
authored and
PxlSyl
committed
Jul 11, 2024
1 parent
9d8b91b
commit 7f41843
Showing
5 changed files
with
123 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from 'react' | ||
|
||
interface LayoutHeaderProps { | ||
title: string | ||
description?: string | ||
} | ||
|
||
const LayoutHeader: React.FC<LayoutHeaderProps> = ({ title, description }) => { | ||
return ( | ||
<div className="space-y-2 pb-8 pt-6 md:space-y-5"> | ||
<h1 className="text-3xl font-extrabold leading-9 tracking-tight text-heading-400 dark:text-heading-400 sm:text-4xl sm:leading-10 md:text-6xl md:leading-14"> | ||
{title} | ||
</h1> | ||
{description && ( | ||
<p className="text-lg leading-7 text-gray-500 dark:text-gray-400">{description}</p> | ||
)} | ||
</div> | ||
) | ||
} | ||
|
||
export default LayoutHeader |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import React from 'react' | ||
import Link from '@/components/mdxcomponents/Link' | ||
import Tag from '@/components/tag' | ||
import { formatDate } from 'pliny/utils/formatDate' | ||
import { LocaleTypes } from 'app/[locale]/i18n/settings' | ||
|
||
interface Post { | ||
slug: string | ||
date: string | ||
title: string | ||
summary?: string | undefined | ||
tags: string[] | ||
language: string | ||
draft?: boolean | ||
} | ||
|
||
interface PostListProps { | ||
posts: Post[] | ||
locale: LocaleTypes | ||
t: (key: string) => string | ||
maxDisplay: number | ||
} | ||
|
||
const PostList: React.FC<PostListProps> = ({ posts, locale, t, maxDisplay }) => { | ||
return ( | ||
<ul className="divide-y divide-gray-200 dark:divide-gray-700"> | ||
{!posts.length && <li>{t('noposts')}</li>} | ||
{posts | ||
.filter((p) => p.language === locale) | ||
.slice(0, maxDisplay) | ||
.map((post) => { | ||
const { slug, date, title, summary, tags } = post | ||
return ( | ||
<li key={slug} className="py-12"> | ||
<article> | ||
<div className="space-y-2 xl:grid xl:grid-cols-4 xl:items-baseline xl:space-y-0"> | ||
<dl> | ||
<dt className="sr-only">{t('pub')}</dt> | ||
<dd className="text-base font-medium leading-6 text-gray-500 dark:text-gray-400"> | ||
<time dateTime={date}>{formatDate(date, locale)}</time> | ||
</dd> | ||
</dl> | ||
<div className="space-y-5 xl:col-span-3"> | ||
<div className="space-y-6"> | ||
<div> | ||
<h2 className="text-2xl font-bold leading-8 tracking-tight"> | ||
<Link | ||
href={`/${locale}/blog/${slug}`} | ||
className="text-gray-900 dark:text-gray-100" | ||
> | ||
{title} | ||
</Link> | ||
</h2> | ||
<ul className="flex flex-wrap"> | ||
{tags.map((tag: string) => ( | ||
<li key={tag}> | ||
<Tag text={tag} /> | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
<div className="prose max-w-none text-gray-500 dark:text-gray-400"> | ||
{summary!.length > 149 ? `${summary!.substring(0, 149)}...` : summary} | ||
</div> | ||
</div> | ||
<div className="text-base font-medium leading-6"> | ||
<Link | ||
href={`/${locale}/blog/${slug}`} | ||
className="text-primary-500 hover:text-primary-600 dark:hover:text-primary-400" | ||
aria-label={`${t('more')}"${title}"`} | ||
> | ||
{t('more')} → | ||
</Link> | ||
</div> | ||
</div> | ||
</div> | ||
</article> | ||
</li> | ||
) | ||
})} | ||
</ul> | ||
) | ||
} | ||
|
||
export default PostList |