diff --git a/gatsby-browser.tsx b/gatsby-browser.tsx index db528e4..80c43ed 100644 --- a/gatsby-browser.tsx +++ b/gatsby-browser.tsx @@ -1,114 +1,7 @@ import './src/styles/main.css'; import * as React from 'react'; -import { MDXProvider } from '@mdx-js/react'; -import { ProblemsListComponent } from './src/components/markdown/Problems'; -import CodeBlock from './src/components/markdown/CodeBlock'; -import SpoilerComponent from './src/components/markdown/SpoilerComponent'; -import { - ResourceComponent, - ResourcesListComponent, -} from './src/components/markdown/Resources'; - -const components = { - 'module-excerpt': props =>
, - spoiler: SpoilerComponent, - 'info-block': ({ - children, - title, - }: { - children: React.ReactNode; - title: string; - }) => ( -
-
-
- - - -
-
-

{title}

-
{children}
-
-
-
- ), - 'warning-block': ({ children }) => ( -
-
-
- - - -
-
-

- Warning! -

-
-

{children}

-
-
-
-
- ), - 'optional-content': ({ - children, - title, - className, - }: { - children: React.ReactNode; - title?: string; - className?: string; - }) => ( -
-
- - - - Optional{title ? `: ${title}` : ''} -
-
{children}
-
- ), - 'problems-list': ProblemsListComponent, - resources: ResourcesListComponent, - resource: ResourceComponent, - code: CodeBlock, - inlineCode: props => ( - - ), - table: props => , - th: props =>
, - td: props => , - h3: props => ( -

- ), - p: props =>

, -}; +import MDXProvider from './src/components/markdown/MDXProvider'; export const wrapRootElement = ({ element }) => ( - {element} + {element} ); diff --git a/gatsby-ssr.js b/gatsby-ssr.js new file mode 100644 index 0000000..75d85b8 --- /dev/null +++ b/gatsby-ssr.js @@ -0,0 +1,6 @@ +// This file shouldn't be necessary, but for some reason Gatsby is not loading +// gatsby-ssr.tsx (note the "x") properly... +module.exports = require('./gatsby-ssr.tsx'); +// this line shouldn't be necessary, but for some reason Gatsby does not load +// gatsby-ssr.js without it... +exports.onRenderBody = () => {}; diff --git a/gatsby-ssr.tsx b/gatsby-ssr.tsx new file mode 100644 index 0000000..14e873b --- /dev/null +++ b/gatsby-ssr.tsx @@ -0,0 +1,6 @@ +import * as React from 'react'; +import MDXProvider from './src/components/markdown/MDXProvider'; + +export const wrapRootElement = ({ element }) => ( + {element} +); diff --git a/src/components/markdown/MDXProvider.tsx b/src/components/markdown/MDXProvider.tsx new file mode 100644 index 0000000..499185e --- /dev/null +++ b/src/components/markdown/MDXProvider.tsx @@ -0,0 +1,110 @@ +import * as React from 'react'; +import { MDXProvider } from '@mdx-js/react'; +import SpoilerComponent from './SpoilerComponent'; +import { ProblemsListComponent } from './Problems'; +import { ResourceComponent, ResourcesListComponent } from './Resources'; +import CodeBlock from './CodeBlock'; + +const components = { + 'module-excerpt': props =>

, + spoiler: SpoilerComponent, + 'info-block': ({ + children, + title, + }: { + children: React.ReactNode; + title: string; + }) => ( +
+
+
+ + + +
+
+

{title}

+
{children}
+
+
+
+ ), + 'warning-block': ({ children }) => ( +
+
+
+ + + +
+
+

+ Warning! +

+
+

{children}

+
+
+
+
+ ), + 'optional-content': ({ + children, + title, + className, + }: { + children: React.ReactNode; + title?: string; + className?: string; + }) => ( +
+
+ + + + Optional{title ? `: ${title}` : ''} +
+
{children}
+
+ ), + 'problems-list': ProblemsListComponent, + resources: ResourcesListComponent, + resource: ResourceComponent, + code: CodeBlock, + inlineCode: props => ( + + ), + table: props => , + th: props => diff --git a/src/utils.ts b/src/utils.ts index d2a302d..7c5e55a 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -43,7 +43,6 @@ export function graphqlToModuleLinks( } export function graphqlToModuleInfo(mdx: any): ModuleInfo { - console.log(mdx.frontmatter); return new ModuleInfo( mdx.frontmatter.id, moduleIDToDivisionMap[mdx.frontmatter.id],
, + td: props => , + h3: props => ( +

+ ), + p: props =>

, +}; + +export default function ({ children }) { + return {children}; +} diff --git a/src/components/markdown/Problems.tsx b/src/components/markdown/Problems.tsx index b09b1b3..d896a21 100644 --- a/src/components/markdown/Problems.tsx +++ b/src/components/markdown/Problems.tsx @@ -8,7 +8,6 @@ type ProblemsListComponentProps = { }; export function ProblemsListComponent(props: ProblemsListComponentProps) { - console.log(props.problems); return (

diff --git a/src/components/markdown/Resources.tsx b/src/components/markdown/Resources.tsx index dfb4620..4d3b0b5 100644 --- a/src/components/markdown/Resources.tsx +++ b/src/components/markdown/Resources.tsx @@ -80,7 +80,7 @@ export function ResourceComponent(props) { fill="currentColor" viewBox="0 0 20 20" > - + )}