generated from Blazity/next-enterprise
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from Blazity/recommended
feat: add recommended articles
- Loading branch information
Showing
7 changed files
with
123 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import Link from "next/link" | ||
import { Locale } from "@/i18n/i18n" | ||
import { getFooter } from "@/lib/client" | ||
|
||
type FooterProps = { | ||
lang: Locale | ||
} | ||
|
||
export async function Footer({ lang }: FooterProps) { | ||
const footer = await getFooter(lang) | ||
|
||
return ( | ||
<footer className="flex w-[100%] items-center justify-between p-4"> | ||
<p>Footer</p> | ||
<nav> | ||
<ul className="flex gap-5"> | ||
{footer.pages.map((footerElement) => ( | ||
<li key={footerElement?.slug}> | ||
<Link href={`/${lang}/${footerElement?.slug}`} prefetch={false}> | ||
{footerElement?.title} | ||
</Link> | ||
</li> | ||
))} | ||
</ul> | ||
</nav> | ||
</footer> | ||
) | ||
} |
40 changes: 40 additions & 0 deletions
40
src/components/RecommendedArticles/RecommendedArticles.tsx
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,40 @@ | ||
import Image from "next/image" | ||
import Link from "next/link" | ||
import { Locale } from "@/i18n/i18n" | ||
|
||
type RecommendedArticle = { | ||
title: string | ||
slug: string | ||
id: string | ||
coverImage?: { url: string } | null | undefined | ||
} | ||
|
||
type RecommendedArticlesProps = { recommendedArticles: RecommendedArticle[]; lang: Locale } | ||
|
||
export async function RecommendedArticles({ recommendedArticles, lang }: RecommendedArticlesProps) { | ||
return ( | ||
<section className="w-full px-4"> | ||
<h2 className="mb-4 text-2xl font-bold">Recommended articles</h2> | ||
<div className="grid grid-cols-2 gap-8 md:grid-cols-4"> | ||
{recommendedArticles?.map((article) => ( | ||
<Link href={`/${lang}/article/${article.slug}`} prefetch={false} passHref key={`recommended-${article.id}`}> | ||
<article className="flex flex-col gap-2"> | ||
<div className="h-[157px] max-w-[300px] rounded-sm bg-slate-100"> | ||
{article?.coverImage?.url && ( | ||
<Image | ||
src={article.coverImage.url} | ||
alt={article.title} | ||
width={300} | ||
height={157} | ||
className="h-[157px] w-[300px] rounded-sm object-cover" | ||
/> | ||
)} | ||
</div> | ||
<div className="font-semibold">{article?.title}</div> | ||
</article> | ||
</Link> | ||
))} | ||
</div> | ||
</section> | ||
) | ||
} |
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