Refactor markdown rendering

pull/1331/head
Kamran Ahmed 5 years ago
parent 77dab81b92
commit ebd351e133
  1. 22
      components/guide-body/index.js
  2. 2
      components/md-renderer/index.js
  3. 0
      components/md-renderer/mdx-components/a.js
  4. 0
      components/md-renderer/mdx-components/blockquote.js
  5. 0
      components/md-renderer/mdx-components/heading.js
  6. 0
      components/md-renderer/mdx-components/iframe.js
  7. 0
      components/md-renderer/mdx-components/img.js
  8. 0
      components/md-renderer/mdx-components/index.js
  9. 0
      components/md-renderer/mdx-components/p.js
  10. 0
      components/md-renderer/mdx-components/pre.js
  11. 0
      components/md-renderer/mdx-components/table.js
  12. 5
      components/roadmap-summary/index.js
  13. 8
      pages/guides/[guide].js

@ -1,13 +1,21 @@
import { MDXProvider } from '@mdx-js/react'; import MdRenderer from 'components/md-renderer'
import MdxComponents from 'components/mdx-components'; import SharePage from 'components/share-page';
import { GuideBodyWrap } from './style'; import { GuideBodyWrap } from './style';
const GuideBody = (props) => ( const GuideBody = ({ guide }) => {
<MDXProvider components={ MdxComponents }> const GuideContent = require(`../../storage/guides/${guide.fileName}.md`).default;
return (
<GuideBodyWrap> <GuideBodyWrap>
{ props.children } <MdRenderer>
<GuideContent />
<SharePage
title={ guide.title }
url={ guide.url }
twitterUsername={ guide.author.twitter }
/>
</MdRenderer>
</GuideBodyWrap> </GuideBodyWrap>
</MDXProvider> );
); };
export default GuideBody; export default GuideBody;

@ -1,5 +1,5 @@
import { MDXProvider } from '@mdx-js/react'; import { MDXProvider } from '@mdx-js/react';
import MdxComponents from 'components/mdx-components'; import MdxComponents from './mdx-components';
const MdRenderer = (props) => ( const MdRenderer = (props) => (
<MDXProvider components={ MdxComponents }> <MDXProvider components={ MdxComponents }>

@ -5,6 +5,7 @@ import SharePage from 'components/share-page';
import { BadgeLink, BadgesList, DarkBadge, PrimaryBadge, SecondaryBadge } from 'components/badges'; import { BadgeLink, BadgesList, DarkBadge, PrimaryBadge, SecondaryBadge } from 'components/badges';
import GuideBody from 'components/guide-body'; import GuideBody from 'components/guide-body';
import siteConfig from "storage/site"; import siteConfig from "storage/site";
import MdRenderer from '../md-renderer';
const UpcomingGuide = require(`../../storage/guides/upcoming.md`).default; const UpcomingGuide = require(`../../storage/guides/upcoming.md`).default;
@ -50,9 +51,9 @@ const RoadmapSummary = ({ roadmap }) => {
<Summary> <Summary>
{ {
roadmap.upcoming && ( roadmap.upcoming && (
<GuideBody> <MdRenderer>
<UpcomingGuide /> <UpcomingGuide />
</GuideBody> </MdRenderer>
) )
} }
{ {

@ -3,7 +3,6 @@ import GuideLayout from 'layouts/guide';
import { serverOnlyProps } from 'lib/server'; import { serverOnlyProps } from 'lib/server';
import GuideHeader from 'components/guide-header'; import GuideHeader from 'components/guide-header';
import GuideBody from 'components/guide-body'; import GuideBody from 'components/guide-body';
import SharePage from 'components/share-page';
import GuideFooter from 'components/guide-footer'; import GuideFooter from 'components/guide-footer';
import { getRequestedGuide } from 'lib/guide'; import { getRequestedGuide } from 'lib/guide';
import Helmet from 'components/helmet'; import Helmet from 'components/helmet';
@ -13,16 +12,11 @@ const Guide = ({ guide }) => {
return <Error statusCode={ 404 } /> return <Error statusCode={ 404 } />
} }
const GuideContent = require(`../../storage/guides/${guide.fileName}.md`).default;
return ( return (
<GuideLayout> <GuideLayout>
<Helmet title={ guide.title } description={ guide.description } /> <Helmet title={ guide.title } description={ guide.description } />
<GuideHeader guide={ guide } /> <GuideHeader guide={ guide } />
<GuideBody> <GuideBody guide={ guide } />
<GuideContent />
<SharePage title={ guide.title } url={ guide.url } twitterUsername={ guide.author.twitter } />
</GuideBody>
<GuideFooter guide={ guide } /> <GuideFooter guide={ guide } />
</GuideLayout> </GuideLayout>
); );

Loading…
Cancel
Save