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';
|
2019-11-08 09:45:15 +04:00
|
|
|
import SharePage from 'components/share-page';
|
2019-11-06 18:20:09 +04:00
|
|
|
import GuideFooter from 'components/guide-footer';
|
2019-11-08 01:32:01 +04:00
|
|
|
import { getRequestedGuide } from 'lib/guide';
|
|
|
|
import Helmet from 'components/helmet';
|
2019-11-01 20:51:32 +04:00
|
|
|
|
|
|
|
const Guide = ({ guide }) => {
|
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-08 01:32:01 +04:00
|
|
|
const GuideContent = require(`../../data/guides/${guide.fileName}.md`).default;
|
|
|
|
|
2019-11-01 20:51:32 +04:00
|
|
|
return (
|
|
|
|
<GuideLayout>
|
2019-11-07 22:38:15 +04:00
|
|
|
<Helmet title={ guide.title } description={ guide.description } />
|
2019-11-06 22:59:43 +04:00
|
|
|
<GuideHeader guide={ guide } />
|
2019-11-02 12:45:15 +04:00
|
|
|
<GuideBody>
|
2019-11-08 01:32:01 +04:00
|
|
|
<GuideContent />
|
2019-11-08 09:45:15 +04:00
|
|
|
<SharePage title={ guide.title } url={ guide.url } twitterUsername={ guide.author.twitter } />
|
2019-11-02 12:45:15 +04:00
|
|
|
</GuideBody>
|
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 {
|
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;
|