Files
pawol.nu/pages/teks/[slug].js
T
Cédric FAMIBELLE-PRONZOLA 02c1053401 Change teks image size in head
2021-05-28 19:08:30 +02:00

51 lines
1.2 KiB
JavaScript

import PropTypes from 'prop-types'
import {jwennTeksEpiSlug, jwennTeks} from '../../lib/oki-api'
import TeksDrawer from '../../components/teks/teks-drawer'
import HeadLayout from '../../components/head-layout'
const jwennAwtis = awtis => {
return awtis.map(a => a.alias).join(', ')
}
export default function SlugTeks({teks, anTeks, slug}) {
const awtis = anTeks.awtis.length === 1 ? anTeks.awtis[0].alias : jwennAwtis(anTeks.awtis)
const {kouveti} = anTeks
return (
<HeadLayout
imageWidth={kouveti ? kouveti.formats.small.width : null}
imageHeight={kouveti ? kouveti.formats.small.height : null}
imageUrl={kouveti ? kouveti.formats.small.url : null}
title={`${awtis} - ${anTeks.tit}`} tab={2} slug={`teks/${slug}`}
>
<TeksDrawer teks={teks} anTeks={anTeks} />
</HeadLayout>
)
}
export async function getServerSideProps({query}) {
const {slug} = query
const teks = await jwennTeks()
const anTeks = await jwennTeksEpiSlug(slug)
if (!anTeks) {
throw new Error('San répons')
}
return {
props: {
teks,
anTeks,
slug
}
}
}
SlugTeks.propTypes = {
teks: PropTypes.array.isRequired,
anTeks: PropTypes.object.isRequired,
slug: PropTypes.string.isRequired
}