Files
pawol.nu/pages/index.js
T

82 lines
2.3 KiB
JavaScript
Raw Normal View History

import PropTypes from 'prop-types'
2022-05-10 02:10:06 +04:00
import {Container, Typography, Box, Divider, Chip} from '@mui/material'
import ArrowCircleDownIcon from '@mui/icons-material/ArrowCircleDown'
2020-12-17 09:08:18 +01:00
2020-12-15 23:46:05 +01:00
import HeadLayout from '../components/head-layout'
2021-06-14 23:30:00 +02:00
import Footer from '../components/footer'
import RezoDialog from '../components/rezo/rezo-dialog'
import DenyeTeks from '../components/teks/denye-teks'
import {jwennDenyeTeks} from '../lib/oki-api'
2020-12-17 22:36:27 +01:00
2022-05-14 03:37:04 +04:00
import Custom500 from './500'
export default function Home({errorCode, errorMessage, teks}) {
if (errorCode) {
console.log('⚠️ error', errorMessage)
return <Custom500 statusCode={errorCode} />
}
2020-12-04 20:16:24 +01:00
return (
2020-12-15 23:46:05 +01:00
<HeadLayout tab={0}>
2022-01-20 18:01:52 +04:00
<Box sx={{display: 'flex', flexDirection: 'column', minHeight: '100vh'}}>
2022-05-10 02:10:06 +04:00
<Box sx={{flexGrow: 1, marginBottom: 4}}>
<Container sx={{marginBottom: 2}} align='center'>
2022-02-01 20:59:38 +04:00
<Typography sx={{fontWeight: 'bold'}} variant='h6' component='h1'>
2022-01-22 12:31:55 +04:00
#OKi
</Typography>
2022-02-01 20:59:38 +04:00
<Typography sx={{fontWeight: 'bold'}} variant='h6' component='h2'>
2022-01-20 18:01:52 +04:00
Organisation KA Internationale
</Typography>
2022-02-01 23:44:18 +04:00
<Typography sx={{fontStyle: 'italic'}} variant='caption' component='h3'>
2022-05-10 16:47:44 +04:00
Paroles, traductions et Fediverse
2022-02-01 20:59:38 +04:00
</Typography>
</Container>
<Container align='center'>
<RezoDialog />
2022-01-20 18:01:52 +04:00
</Container>
</Box>
2022-05-14 03:37:04 +04:00
<Container sx={{flexGrow: 100}}>
<Divider variant='middle' sx={{marginBottom: 1}}>
<Chip sx={{fontWeight: 'bold'}} color='primary' icon={<ArrowCircleDownIcon />} label='Derniers textes publiés ' variant='outlined' />
</Divider>
2022-05-14 03:37:04 +04:00
<DenyeTeks denyeTeks={teks} />
</Container>
2021-06-14 23:30:00 +02:00
<Footer />
2022-01-20 18:01:52 +04:00
</Box>
2020-12-15 23:46:05 +01:00
</HeadLayout>
2020-12-04 20:16:24 +01:00
)
}
export async function getServerSideProps() {
2022-05-14 03:37:04 +04:00
let denyeTeks
let errorCode
let errorMessage
try {
denyeTeks = await jwennDenyeTeks()
} catch (error) {
errorMessage = error.message
errorCode = true
}
return {
props: {
2022-05-14 03:37:04 +04:00
errorCode: errorCode || null,
errorMessage: errorMessage || null,
teks: denyeTeks || null
}
}
}
2022-05-14 03:37:04 +04:00
Home.defaultProps = {
errorCode: null,
errorMessage: null,
teks: null
}
Home.propTypes = {
2022-05-14 03:37:04 +04:00
errorCode: PropTypes.bool,
errorMessage: PropTypes.string,
teks: PropTypes.array
}