diff --git a/app/blog/[id]/page.js b/app/blog/[id]/page.js new file mode 100644 index 00000000..a6b7a876 --- /dev/null +++ b/app/blog/[id]/page.js @@ -0,0 +1,103 @@ +import Link from 'next/link' + +import { convertMarkdownToHtml, convertToStringDate } from '@/services/utils' +import ArrowLeftIcon from '@/components/Icons/ArrowLeftIcon' +import getAllArticle from '@/services/getAllArticle' +import getOneArticle from '@/services/getOneArticle' +import { Layout } from '@/components/Global/Layout' +import Footer from '@/components/Global/Footer' +import CTA from '@/components/Global/CTA' +import Nav from '@/components/Global/Nav' + +export const dynamicParams = false +export const revalidate = 10 + +export const generateStaticParams = async () => { + const articleList = await getAllArticle() + + const pathList = articleList?.map(record => ({ + id: record.attributes.slug, + })) + + return pathList || [] +} + +export const generateMetadata = async ({ params }) => { + const article = await getOneArticle(params.id) + + const meta = article?.attributes + return { + description: + meta?.seo_description ?? + 'Découvrez cet article passionnant de la part de My-Makeup', + // seo tag canonical link + alternates: { + canonical: 'https://my-makeup.fr/blog/' + meta?.slug, + }, + title: meta?.seo_title ?? 'My-Makeup', + } +} + +const BlogArticle = async ({ params }) => { + const { id } = params + const article = await getOneArticle(id) + const articleWithConvertedContent = await convertMarkdownToHtml(article) + const articleAttributes = articleWithConvertedContent?.attributes + + return ( + <> +