diff --git a/app/page.js b/app/page.js index 2695830..7592a11 100644 --- a/app/page.js +++ b/app/page.js @@ -1,7 +1,7 @@ import Box from '@mui/material/Box' import Container from '@mui/material/Container' import {notFound} from 'next/navigation' -import {jwennStats, jwennDenyeTeks} from '../lib/oki-api' +import {jwennStats, jwennDenyeTeks, jwennAnVedette} from '../lib/oki-api' import Statistik from '../components/akey/statistik' import Akey from '../components/akey' @@ -12,13 +12,13 @@ import Footer from '../components/footer' import Aso from '../components/akey/aso' async function jwennDone() { - const [statistik, denyeTeks] = await Promise.all([jwennStats(), jwennDenyeTeks()]) + const [statistik, denyeTeks, anVedette] = await Promise.all([jwennStats(), jwennDenyeTeks(), jwennAnVedette()]) if (!statistik) { notFound() } - return {statistik, dernierTeks: denyeTeks?.[0]} + return {statistik, dernierTeks: anVedette ?? denyeTeks?.[0]} } export default async function Page() { diff --git a/lib/oki-api.js b/lib/oki-api.js index fe4c92f..341c51e 100644 --- a/lib/oki-api.js +++ b/lib/oki-api.js @@ -229,6 +229,25 @@ export async function jwennDenyeTeks() { return data } +export async function jwennAnVedette() { + const query = qs.stringify({ + populate: ['artistes', 'couverture'], + filters: { + isNewRelease: { $eq: true } + }, + pagination: { limit: 1 } + }, { + encodeValuesOnly: true + }) + + const {data} = await request(`/paroles?${query}`, { + next: {revalidate: 0}, + headers: {Authorization: `Bearer ${readToken}`} + }) + + return data?.[0] ?? null +} + export async function jwennAnTeks(teksId, token) { const headers = { 'content-type': 'application/json',