2020-12-13 23:20:07 +01:00
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
|
|
2020-12-18 22:08:34 +01:00
|
|
|
import {jwennTeksEpiSlug, jwennTeks} from '../../lib/oki-api'
|
2020-12-13 23:20:07 +01:00
|
|
|
|
|
|
|
|
import TeksDrawer from '../../components/teks/teks-drawer'
|
2020-12-15 23:46:05 +01:00
|
|
|
import HeadLayout from '../../components/head-layout'
|
2020-12-13 23:20:07 +01:00
|
|
|
|
2021-03-07 15:18:58 +01:00
|
|
|
const jwennAwtis = awtis => {
|
|
|
|
|
return awtis.map(a => a.alias).join(', ')
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-24 13:39:07 +01:00
|
|
|
export default function SlugTeks({teks, anTeks, slug}) {
|
2021-03-07 15:22:56 +01:00
|
|
|
const awtis = anTeks.awtis.length === 1 ? anTeks.awtis[0].alias : jwennAwtis(anTeks.awtis)
|
2021-05-28 18:29:15 +02:00
|
|
|
const {kouveti} = anTeks
|
2021-03-07 15:18:58 +01:00
|
|
|
|
2020-12-13 23:20:07 +01:00
|
|
|
return (
|
2021-05-28 18:29:15 +02:00
|
|
|
<HeadLayout
|
2021-05-28 19:08:30 +02:00
|
|
|
imageWidth={kouveti ? kouveti.formats.small.width : null}
|
|
|
|
|
imageHeight={kouveti ? kouveti.formats.small.height : null}
|
|
|
|
|
imageUrl={kouveti ? kouveti.formats.small.url : null}
|
2021-05-28 18:29:15 +02:00
|
|
|
title={`${awtis} - ${anTeks.tit}`} tab={2} slug={`teks/${slug}`}
|
|
|
|
|
>
|
2020-12-18 22:08:34 +01:00
|
|
|
<TeksDrawer teks={teks} anTeks={anTeks} />
|
2020-12-15 23:46:05 +01:00
|
|
|
</HeadLayout>
|
2020-12-13 23:20:07 +01:00
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function getServerSideProps({query}) {
|
|
|
|
|
const {slug} = query
|
2020-12-18 22:08:34 +01:00
|
|
|
const teks = await jwennTeks()
|
|
|
|
|
const anTeks = await jwennTeksEpiSlug(slug)
|
2020-12-13 23:20:07 +01:00
|
|
|
|
2020-12-18 22:08:34 +01:00
|
|
|
if (!anTeks) {
|
2020-12-13 23:20:07 +01:00
|
|
|
throw new Error('San répons')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
props: {
|
2020-12-18 22:08:34 +01:00
|
|
|
teks,
|
2020-12-24 13:39:07 +01:00
|
|
|
anTeks,
|
|
|
|
|
slug
|
2020-12-13 23:20:07 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-18 22:08:34 +01:00
|
|
|
SlugTeks.propTypes = {
|
|
|
|
|
teks: PropTypes.array.isRequired,
|
2020-12-24 13:39:07 +01:00
|
|
|
anTeks: PropTypes.object.isRequired,
|
|
|
|
|
slug: PropTypes.string.isRequired
|
2020-12-13 23:20:07 +01:00
|
|
|
}
|