From 90785570b00eac61f292b6385cae28cbdc2fb4f4 Mon Sep 17 00:00:00 2001 From: fansoa Date: Fri, 30 Aug 2024 15:48:07 +0200 Subject: [PATCH 01/25] add getAllArticles service --- src/services/getAllArticles.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/services/getAllArticles.js diff --git a/src/services/getAllArticles.js b/src/services/getAllArticles.js new file mode 100644 index 00000000..263e312e --- /dev/null +++ b/src/services/getAllArticles.js @@ -0,0 +1,29 @@ +async function fetchAPI(url) { + try { + const res = await fetch(url, { + headers: { + 'Content-Type': 'application/json', + Accept: 'application/json', + }, + method: 'GET', + }) + return res.json() + } catch (error) { + console.error(`🚀 ~ fetchAPI ~ ${url} ~ res:`, error) + } +} + +export const getAllArticles = async () => { + const articles = await fetchAPI( + `${process.env.NEXT_PUBLIC_API_URL}/api/artdicles` + ) + + const talents = await fetchAPI( + `${process.env.NEXT_PUBLIC_API_URL}/api/talents` + ) + + return { + articles: articles?.data, + talents: talents?.data, + } +} From 73477a1813218a2561c60fa0b03e8087f44ed13d Mon Sep 17 00:00:00 2001 From: fansoa Date: Fri, 30 Aug 2024 15:52:50 +0200 Subject: [PATCH 02/25] migrate site-map --- src/pages/site-map.js => app/site-map/page.js | 53 +++++-------------- 1 file changed, 13 insertions(+), 40 deletions(-) rename src/pages/site-map.js => app/site-map/page.js (82%) diff --git a/src/pages/site-map.js b/app/site-map/page.js similarity index 82% rename from src/pages/site-map.js rename to app/site-map/page.js index 2cc1c1fc..718cf0bd 100644 --- a/src/pages/site-map.js +++ b/app/site-map/page.js @@ -1,27 +1,25 @@ -import React from 'react' - -import Head from 'next/head' import Link from 'next/link' +import { getAllArticles } from '@/services/getAllArticles' import Footer from '@/components/Global/Footer' import Hero from '@/components/Global/Hero' import Nav from '@/components/Global/Nav' import CTA from '@/components/Global/CTA' -/** - * @param props - * @constructor - */ -function SiteMap({ articles, talents }) { +export const metadata = { + // seo tag canonical link + alternates: { + canonical: 'https://my-makeup.fr/site-map', + }, + description: 'Le plan du site de My-Makeup', + title: 'Site Map My-Makeup !', +} + +async function SiteMap() { + const { articles, talents } = await getAllArticles() + return ( <> - - Site Map My-Makeup ! - - {/* seo tag canonical link */} - - -