2019-11-06 18:20:09 +04:00
|
|
|
import Error from "next/error";
|
|
|
|
import GuideLayout from 'layouts/guide';
|
|
|
|
import { serverOnlyProps } from 'lib/server';
|
|
|
|
import GuideHeader from 'components/guide-header';
|
|
|
|
import GuideBody from 'components/guide-body';
|
|
|
|
import GuideFooter from 'components/guide-footer';
|
2019-11-08 01:32:01 +04:00
|
|
|
import { getRequestedGuide } from 'lib/guide';
|
|
|
|
import Helmet from 'components/helmet';
|
2020-01-18 22:47:48 +04:00
|
|
|
import siteConfig from 'content/site';
|
2019-11-01 20:51:32 +04:00
|
|
|
|
2020-01-17 19:18:47 +04:00
|
|
|
const Guide = ({ guide, canonical }) => {
|
2019-11-06 18:20:09 +04:00
|
|
|
if (!guide) {
|
2019-11-07 22:38:15 +04:00
|
|
|
return <Error statusCode={ 404 } />
|
2019-11-06 18:20:09 +04:00
|
|
|
}
|
|
|
|
|
2019-11-01 20:51:32 +04:00
|
|
|
return (
|
|
|
|
<GuideLayout>
|
2020-01-17 19:18:47 +04:00
|
|
|
<Helmet
|
|
|
|
title={ guide.title }
|
|
|
|
description={ guide.description }
|
|
|
|
canonical={ guide.canonical || canonical }
|
|
|
|
/>
|
2019-11-06 22:59:43 +04:00
|
|
|
<GuideHeader guide={ guide } />
|
2019-11-29 18:36:49 +04:00
|
|
|
<GuideBody guide={ guide } />
|
2019-11-06 22:59:43 +04:00
|
|
|
<GuideFooter guide={ guide } />
|
2019-11-01 20:51:32 +04:00
|
|
|
</GuideLayout>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2019-11-08 01:32:01 +04:00
|
|
|
Guide.getInitialProps = serverOnlyProps(async ({ req }) => {
|
2019-11-01 20:51:32 +04:00
|
|
|
return {
|
2020-01-17 19:18:47 +04:00
|
|
|
canonical: `${siteConfig.url.web}${req.url}`,
|
2019-11-08 01:32:01 +04:00
|
|
|
guide: await getRequestedGuide(req),
|
2019-11-01 20:51:32 +04:00
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2019-11-03 11:47:31 +04:00
|
|
|
export default Guide;
|