-
-
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.
- Loading branch information
PxlSyl
authored and
PxlSyl
committed
Apr 27, 2024
1 parent
ee2a4d0
commit 4bb53fa
Showing
9 changed files
with
140 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import Link from '@/components/Link' | ||
import Tag from '@/components/Tag' | ||
import { formatDate } from 'pliny/utils/formatDate' | ||
import { createTranslation } from './i18n/server' | ||
import { LocaleTypes } from './i18n/settings' | ||
|
||
interface Post { | ||
slug: string | ||
date: string | ||
title: string | ||
summary?: string | undefined | ||
tags: string[] | ||
language: string | ||
draft?: boolean | ||
featured?: boolean | ||
} | ||
|
||
interface HomeProps { | ||
posts: Post[] | ||
params: { locale: LocaleTypes } | ||
} | ||
|
||
const MAX_DISPLAY = 2 | ||
|
||
export default async function Featured({ posts, params: { locale } }: HomeProps) { | ||
const { t } = await createTranslation(locale, 'home') | ||
return ( | ||
<> | ||
<div className="divide-y divide-gray-200 dark:divide-gray-700 border-b border-gray-200 dark:border-gray-700"> | ||
<div className="space-y-2 pb-8 pt-6 md:space-y-5"> | ||
<h1 className="text-3xl font-extrabold leading-9 tracking-tight text-blue-400 dark:text-blue-400 sm:text-4xl sm:leading-10 md:text-6xl md:leading-14"> | ||
{t('featured')} | ||
</h1> | ||
</div> | ||
<ul className="divide-y divide-gray-200 dark:divide-gray-700"> | ||
{!posts.length && t('noposts')} | ||
{posts | ||
.filter((p) => p.language === locale && p.featured === true) | ||
.slice(0, MAX_DISPLAY) | ||
.map((post) => { | ||
const { slug, date, title, summary, tags, language } = post | ||
if (language === locale) { | ||
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> | ||
<div className="flex flex-wrap"> | ||
{tags.map((tag: string) => ( | ||
<Tag key={tag} text={tag} params={{ locale: locale }} /> | ||
))} | ||
</div> | ||
</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> | ||
</div> | ||
</> | ||
) | ||
} |
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 |
---|---|---|
@@ -1,50 +1,50 @@ | ||
{ | ||
"codesample": { | ||
"en": "posts/code-sample", | ||
"fr": "articles/exemple-code" | ||
}, | ||
"derivingols": { | ||
"en": "posts/deriving-ols-estimator", | ||
"fr": "articles/derivation-estimateur-ols" | ||
"introducingstarterblogi18n": { | ||
"fr": "articles/internationalisation-v2", | ||
"en": "posts/internationalization-v2" | ||
}, | ||
"mardownguide": { | ||
"en": "posts/github-markdown-guide", | ||
"fr": "articles/guide-github-markdown" | ||
"releasev2": { | ||
"fr": "articles/presentation-starter-blog-tailwind-nextjs-v2.0", | ||
"en": "posts/release-of-tailwind-nextjs-starter-blog-v2.0" | ||
}, | ||
"nextjsimagesguide": { | ||
"en": "posts/guide-to-using-images-in-nextjs", | ||
"fr": "articles/guide-utilisation-images-nextjs" | ||
"newfeaturesv1": { | ||
"fr": "articles/nouvelles-fonctionnalites-v1", | ||
"en": "posts/new-features-in-v1" | ||
}, | ||
"canadapictures": { | ||
"en": "posts/images-du-canada", | ||
"fr": "articles/pictures-of-canada" | ||
"nestedroutes": { | ||
"fr": "articles/route-imbriquee/presentation-publications-en-plusieurs-parties-routage-imbrique", | ||
"en": "posts/nested-route/introducing-multi-part-posts-with-nested-routing" | ||
}, | ||
"introducingstarterblogi18n": { | ||
"en": "posts/internationalization-v2", | ||
"fr": "articles/internationalisation-v2" | ||
"myfancytitle": { | ||
"fr": "articles/mon-titre-fancy", | ||
"en": "posts/my-fancy-title" | ||
}, | ||
"introducingstarterblog": { | ||
"en": "posts/introducing-tailwind-nextjs-starter-blog", | ||
"fr": "articles/presentation-blog-starter-tailwind-nextjs" | ||
"fr": "articles/presentation-blog-starter-tailwind-nextjs", | ||
"en": "posts/introducing-tailwind-nextjs-starter-blog" | ||
}, | ||
"myfancytitle": { | ||
"en": "posts/my-fancy-title", | ||
"fr": "articles/mon-titre-fancy" | ||
"derivingols": { | ||
"fr": "articles/derivation-estimateur-ols", | ||
"en": "posts/deriving-ols-estimator" | ||
}, | ||
"newfeaturesv1": { | ||
"en": "posts/new-features-in-v1", | ||
"fr": "articles/nouvelles-fonctionnalites-v1" | ||
"nextjsimagesguide": { | ||
"fr": "articles/guide-utilisation-images-nextjs", | ||
"en": "posts/guide-to-using-images-in-nextjs" | ||
}, | ||
"releasev2": { | ||
"en": "posts/release-of-tailwind-nextjs-starter-blog-v2.0", | ||
"fr": "articles/presentation-starter-blog-tailwind-nextjs-v2.0" | ||
"mardownguide": { | ||
"fr": "articles/guide-github-markdown", | ||
"en": "posts/github-markdown-guide" | ||
}, | ||
"thetimemachine": { | ||
"en": "posts/the-time-machine", | ||
"fr": "articles/la-machine-a-remonter-le-temps" | ||
"fr": "articles/la-machine-a-remonter-le-temps", | ||
"en": "posts/the-time-machine" | ||
}, | ||
"nestedroutes": { | ||
"en": "posts/nested-route/introducing-multi-part-posts-with-nested-routing", | ||
"fr": "articles/route-imbriquee/presentation-publications-en-plusieurs-parties-routage-imbrique" | ||
"canadapictures": { | ||
"fr": "articles/pictures-of-canada", | ||
"en": "posts/images-du-canada" | ||
}, | ||
"codesample": { | ||
"fr": "articles/exemple-code", | ||
"en": "posts/code-sample" | ||
} | ||
} |
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 |
---|---|---|
@@ -1 +1 @@ | ||
{"en":{"markdown":1,"code":1,"features":2,"next-js":7,"math":1,"ols":1,"github":1,"guide":6,"holiday":1,"canada":1,"images":1,"tailwind":4,"i18n":1,"hello":1,"feature":2,"writings":1,"book":1,"reflection":1,"multi-author":1},"fr":{"next-js":7,"math":1,"ols":1,"markdown":1,"code":1,"fonctionnalites":4,"github":1,"guide":6,"tailwind":4,"i18n":1,"ecriture":1,"livre":1,"reflexion":1,"salut":1,"vacance":1,"canada":1,"images":1,"multi-auteurs":1}} | ||
{"en":{"next-js":7,"tailwind":4,"guide":6,"features":2,"i18n":1,"feature":2,"multi-author":1,"hello":1,"math":1,"ols":1,"github":1,"writings":1,"book":1,"reflection":1,"holiday":1,"canada":1,"images":1,"markdown":1,"code":1},"fr":{"next-js":7,"tailwind":4,"guide":6,"fonctionnalites":4,"i18n":1,"multi-auteurs":1,"salut":1,"math":1,"ols":1,"github":1,"ecriture":1,"livre":1,"reflexion":1,"vacance":1,"canada":1,"images":1,"markdown":1,"code":1}} |
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