From ff992e04ed530c080ec9d2d3809979d1b27dbd7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Famibelle-Pronzola?= Date: Sat, 22 Jul 2023 13:28:30 +0400 Subject: [PATCH] Move paroles pages to app directory --- app/paroles/[slug]/page.js | 105 +++++++++++++++++++++++++++++++++++++ app/paroles/layout.js | 61 +++++++++++++++++++++ app/paroles/loading.js | 17 ++++++ app/paroles/page.js | 32 +++++++++++ pages/paroles/[slug].js | 96 --------------------------------- pages/paroles/index.js | 54 ------------------- 6 files changed, 215 insertions(+), 150 deletions(-) create mode 100644 app/paroles/[slug]/page.js create mode 100644 app/paroles/layout.js create mode 100644 app/paroles/loading.js create mode 100644 app/paroles/page.js delete mode 100644 pages/paroles/[slug].js delete mode 100644 pages/paroles/index.js diff --git a/app/paroles/[slug]/page.js b/app/paroles/[slug]/page.js new file mode 100644 index 0000000..0a8f1eb --- /dev/null +++ b/app/paroles/[slug]/page.js @@ -0,0 +1,105 @@ +import {notFound} from 'next/navigation' +import Box from '@mui/material/Box' + +import {jwennTeksEpiSlug} from '../../../lib/oki-api' +import AnTeks from '../../../components/teks/an-teks' +import {getAlias} from '../../../lib/utils/format' +import {formatKuveti} from '../../../lib/kuveti' + +const apiUrl = process.env.NEXT_PUBLIC_API_URL_ROOT || 'http://localhost:1337' +const siteUrl = process.env.NEXT_PUBLIC_SITE_URL || 'http://localhost:3000' +const drawerWidth = 340 + +async function jwennAnTeks(slug) { + const teks = await jwennTeksEpiSlug(slug) + + if (!teks) { + notFound() + } + + return teks +} + +export async function generateMetadata({params}) { + const {slug} = params + + const anTeks = await jwennAnTeks(slug) + + const awtis = anTeks.attributes.artistes.length === 1 ? anTeks.attributes.artistes[0].data.attributes.alias : getAlias(anTeks.attributes.artistes, anTeks.attributes.prioriteArtistes) + const title = `OKI | ${awtis} - ${anTeks.attributes.titre} | Paroles et Traductions` + const description = `Paroles de « ${anTeks?.attributes?.titre} » : ${anTeks?.attributes?.transcription.slice(0, 100)}...` + const url = `${siteUrl}/${slug}` + + const {couverture} = anTeks.attributes + const kuvetiFormat = formatKuveti(couverture) + + return { + title, + description, + openGraph: { + title, + description, + url, + siteName: title, + images: [ + { + url: `${apiUrl}${kuvetiFormat?.url}`, + width: kuvetiFormat?.width, + height: kuvetiFormat?.height + } + ], + locale: 'fr_FR', + type: 'website' + }, + twitter: { + site: '@OrganisationKA', + card: 'summary_large_image', + title, + description, + creator: '@OrganisationKA', + images: { + url: `${apiUrl}${kuvetiFormat?.url}`, + alt: `Couverture ${title}`, + } + } + } +} + +export default async function AnPawolPaj({params}) { + const {slug} = params + + const anTeks = await jwennAnTeks(slug) + + const jsonLd = { + '@context': 'http://schema.org', + '@type': 'MusicRecording', + name: anTeks.attributes.titre, + url: `${siteUrl}/paroles/${slug}`, + byArtist: anTeks.attributes.artistes.data.map(({attributes}) => ({ + '@type': 'Person', + name: attributes.alias, + url: `${siteUrl}/awtis/${attributes.slug}` + })), + datePublished: anTeks.attributes?.annee + } + + return ( + <> + + + + + + +
+