Files
pawol.nu/app/paroles/page.js
T

69 lines
2.0 KiB
JavaScript
Raw Normal View History

2023-07-22 13:28:30 +04:00
import Box from '@mui/material/Box'
import {notFound} from 'next/navigation'
import {jwennDenyeTeks} from '../../lib/oki-api'
2026-06-08 01:37:59 +04:00
import {formatKuveti} from '../../lib/kuveti'
2023-07-22 13:28:30 +04:00
import DenyeTeks from '../../components/teks/denye-teks'
2023-07-22 23:38:08 +04:00
import Footer from '../../components/footer'
2023-07-22 13:28:30 +04:00
2026-06-08 01:37:59 +04:00
const apiUrl = process.env.NEXT_PUBLIC_API_URL_ROOT || 'http://localhost:1337'
const siteUrl = process.env.NEXT_PUBLIC_SITE_URL || 'http://localhost:3000'
2023-07-22 13:28:30 +04:00
async function jwennDone() {
const denyeTeks = await jwennDenyeTeks()
if (!denyeTeks) {
notFound()
}
return denyeTeks
}
2026-06-08 01:37:59 +04:00
export async function generateMetadata() {
const denyeTeks = await jwennDone()
const couverture = formatKuveti(denyeTeks[0]?.couverture)
const imageUrl = couverture?.url ? `${apiUrl}${couverture.url}` : `${siteUrl}/logo-512x512.png`
const imageWidth = couverture?.width || 512
const imageHeight = couverture?.height || 512
const songList = denyeTeks.slice(0, 3).map(t => `${t.artistes[0]?.alias} ${t.titre}`).join(', ')
const description = `Derniers morceaux : ${songList}`
return {
title: 'PAWÒL-NU | Derniers morceaux',
description,
openGraph: {
title: 'PAWÒL-NU | Derniers morceaux',
description,
url: `${siteUrl}/paroles`,
siteName: 'PAWÒL-NU. Paroles et traductions.',
images: [{url: imageUrl, width: imageWidth, height: imageHeight}],
locale: 'fr_FR',
type: 'website',
},
twitter: {
site: '@OrganisationKA',
card: 'summary_large_image',
title: 'PAWÒL-NU | Derniers morceaux',
description,
creator: '@OrganisationKA',
images: {url: imageUrl, alt: 'Couverture du dernier morceau publié'},
},
}
}
2023-07-22 13:28:30 +04:00
export default async function PawolPaj() {
const denyeTeks = await jwennDone()
return (
2023-07-22 23:38:08 +04:00
<Box sx={{display: 'flex', flexDirection: 'column', minHeight: '100vh'}}>
2023-07-22 13:28:30 +04:00
<Box
component='main'
2023-07-22 23:38:08 +04:00
sx={{flexGrow: 1, p: 2, mt: 2}}
2023-07-22 13:28:30 +04:00
>
<DenyeTeks denyeTeks={denyeTeks} />
</Box>
2023-07-22 23:38:08 +04:00
<Footer />
2023-07-22 13:28:30 +04:00
</Box>
)
}