Adapt all Teks components to new api

This commit is contained in:
2020-12-18 22:08:34 +01:00
parent 94cc53410d
commit 81a5ed4ce0
6 changed files with 60 additions and 61 deletions
+12 -12
View File
@@ -1,36 +1,36 @@
import PropTypes from 'prop-types'
import {jwennMizikEpiSlug, jwennTeks} from '../../lib/oki-api'
import {jwennTeksEpiSlug, jwennTeks} from '../../lib/oki-api'
import TeksDrawer from '../../components/teks/teks-drawer'
import HeadLayout from '../../components/head-layout'
export default function Mizik({miziks, mizik}) {
export default function SlugTeks({teks, anTeks}) {
return (
<HeadLayout title={`Tèks | ${mizik[0].titre}`} tab={2}>
<TeksDrawer miziks={miziks} mizik={mizik} />
<HeadLayout title={`Tèks | ${anTeks.tit}`} tab={2}>
<TeksDrawer teks={teks} anTeks={anTeks} />
</HeadLayout>
)
}
export async function getServerSideProps({query}) {
const {slug} = query
const miziks = await jwennTeks()
const mizik = await jwennMizikEpiSlug(slug)
const teks = await jwennTeks()
const anTeks = await jwennTeksEpiSlug(slug)
if (mizik.length === 0) {
if (!anTeks) {
throw new Error('San répons')
}
return {
props: {
miziks,
mizik
teks,
anTeks
}
}
}
Mizik.propTypes = {
miziks: PropTypes.array.isRequired,
mizik: PropTypes.array.isRequired
SlugTeks.propTypes = {
teks: PropTypes.array.isRequired,
anTeks: PropTypes.object.isRequired
}