Adapt components with API response
This commit is contained in:
+16
-17
@@ -24,14 +24,14 @@ export async function generateMetadata(props) {
|
||||
const params = await props.params;
|
||||
const {slug} = params
|
||||
|
||||
const anTeks = await jwennAnTeks(slug)
|
||||
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 awtis = anTeks?.artistes?.length === 1 ? anTeks?.artistes[0].alias : getAlias(anTeks.artistes, anTeks.prioriteArtistes)
|
||||
const title = `OKI | ${awtis} - ${anTeks.titre} | Paroles et Traductions`
|
||||
const description = `Paroles de « ${anTeks?.titre} » : ${anTeks?.transcription.slice(0, 100)}...`
|
||||
const url = `${siteUrl}/paroles/${slug}`
|
||||
|
||||
const {couverture} = anTeks.attributes
|
||||
const {couverture} = anTeks
|
||||
const kuvetiFormat = formatKuveti(couverture)
|
||||
|
||||
return {
|
||||
@@ -71,30 +71,29 @@ export default async function AnPawolPaj(props) {
|
||||
const {slug} = params
|
||||
|
||||
const anTeks = await jwennAnTeks(slug)
|
||||
const {couverture} = anTeks.attributes
|
||||
const teksKuvetiFormat = formatKuveti(couverture)
|
||||
const {couverture} = anTeks
|
||||
const teksKuvetiFormat = formatKuveti(couverture)
|
||||
|
||||
const jsonLd = {
|
||||
'@context': 'http://schema.org',
|
||||
'@type': 'MusicRecording',
|
||||
'@id': anTeks.attributes.musicBrainzUrl || undefined,
|
||||
name: anTeks.attributes.titre,
|
||||
'@id': anTeks.musicBrainzUrl || undefined,
|
||||
name: anTeks.titre,
|
||||
url: `${siteUrl}/paroles/${slug}`,
|
||||
image: teksKuvetiFormat?.url ? `${apiUrl}${teksKuvetiFormat?.url}` : undefined,
|
||||
thumbnailUrl: couverture?.data?.attributes?.formats?.thumbnail?.url ? `${apiUrl}${couverture.data.attributes.formats.thumbnail.url}` : undefined,
|
||||
byArtist: anTeks.attributes.artistes.data.map(({attributes}) => {
|
||||
const {photo} = attributes
|
||||
thumbnailUrl: couverture?.formats?.thumbnail?.url ? `${apiUrl}${couverture.formats.thumbnail.url}` : undefined,
|
||||
byArtist: anTeks.artistes.map(({photo, musicBrainzUrl, alias, slug}) => {
|
||||
const kuvetiFormat = formatKuveti(photo)
|
||||
|
||||
return {
|
||||
'@type': 'Person',
|
||||
'@id': attributes.musicBrainzUrl || undefined,
|
||||
name: attributes.alias,
|
||||
url: `${siteUrl}/awtis/${attributes.slug}`,
|
||||
'@id': musicBrainzUrl || undefined,
|
||||
name: alias,
|
||||
url: `${siteUrl}/awtis/${slug}`,
|
||||
image: kuvetiFormat?.url ? `${apiUrl}${kuvetiFormat?.url}` : undefined
|
||||
}
|
||||
}),
|
||||
datePublished: anTeks.attributes?.annee
|
||||
datePublished: anTeks?.annee
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -104,7 +103,7 @@ export default async function AnPawolPaj(props) {
|
||||
component='main'
|
||||
sx={{flexGrow: 1, p: 2, mt: 2}}
|
||||
>
|
||||
<AnTeks parole={anTeks.attributes} paroleId={anTeks.id} />
|
||||
<AnTeks parole={anTeks} paroleId={anTeks.id} />
|
||||
</Box>
|
||||
<Footer />
|
||||
</Box>
|
||||
|
||||
Reference in New Issue
Block a user