Skip to content

Commit

Permalink
Add about page
Browse files Browse the repository at this point in the history
Add mdx parsing
  • Loading branch information
Marvin Heilemann committed Jan 11, 2020
1 parent a1a4bb9 commit e4fdc15
Show file tree
Hide file tree
Showing 18 changed files with 1,212 additions and 27 deletions.
1 change: 1 addition & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
- [ ] replace React with [Preact][1] (check if it works when finished)
- [ ] new image for start: me while coding
- [ ] new image for start: me while writing
- [ ] put scss theme stuff in own mixin for compat.
- [ ] Add footer with: version, social-media, imprint, changelog, copyright
notice
- [x] test react helmet async
Expand Down
10 changes: 10 additions & 0 deletions gatsby-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
* @see https://www.gatsbyjs.org/docs/browser-apis/
*/

const React = require('react')
const { MDXProvider } = require('@mdx-js/react')

const { isProd, isDev } = require('./gatsby/environment')

const printCorporateMessage = require('./gatsby/browser/corporateMessage')
const setDefaultTime = require('./gatsby/browser/defaultTime')
const mdxCustomComponents = require('./gatsby/browser/mdxCustomComponents')

require('./src/styles/app.scss')

Expand All @@ -28,3 +32,9 @@ exports.onRouteUpdate = ({ location }) => {
console.info('Track pageview of:', path)
}
}

exports.wrapRootElement = ({ element }) => (
<MDXProvider components={mdxCustomComponents.components}>
{element}
</MDXProvider>
)
1 change: 1 addition & 0 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ module.exports = {
'gatsby-transformer-json',
'gatsby-plugin-sharp',
'gatsby-transformer-sharp',
`gatsby-plugin-mdx`,
{
resolve: `gatsby-source-filesystem`,
options: {
Expand Down
122 changes: 122 additions & 0 deletions gatsby/browser/mdxCustomComponents.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
const React = require('react')

const Container = ({ children }) => <div className="container">{children}</div>
const ContainerSmall = ({ children }) => (
<div className="container container--small">{children}</div>
)

/*
eslint-disable
jsx-a11y/heading-has-content,
jsx-a11y/anchor-has-content,
jsx-a11y/alt-text
*/
const Paragraph = (props) => (
<ContainerSmall>
<p {...props} />
</ContainerSmall>
)
const Headline1 = (props) => (
<ContainerSmall>
<h1 {...props} />
</ContainerSmall>
)
const Headline2 = (props) => (
<ContainerSmall>
<h2 {...props} />
</ContainerSmall>
)
const Headline3 = (props) => (
<ContainerSmall>
<h3 {...props} />
</ContainerSmall>
)
const Headline4 = (props) => (
<ContainerSmall>
<h4 {...props} />
</ContainerSmall>
)
const Headline5 = (props) => (
<ContainerSmall>
<h5 {...props} />
</ContainerSmall>
)
const Headline6 = (props) => (
<ContainerSmall>
<h6 {...props} />
</ContainerSmall>
)
const ThematicBreak = (props) => (
<ContainerSmall>
<br {...props} />
</ContainerSmall>
)
const Blockquote = (props) => (
<ContainerSmall>
<blockquote {...props} />
</ContainerSmall>
)
const UnorderedList = (props) => (
<ContainerSmall>
<ul {...props} />
</ContainerSmall>
)
const OrderedList = (props) => (
<ContainerSmall>
<ol {...props} />
</ContainerSmall>
)
const ListElement = (props) => <li {...props} />
const Table = (props) => (
<ContainerSmall>
<table {...props} />
</ContainerSmall>
)
const TableRow = (props) => <tr {...props} />
const TableCell = (props) => <td {...props} />
const PreformattedCode = (props) => (
<ContainerSmall>
<pre {...props} />
</ContainerSmall>
)
const InlineCode = (props) => <code {...props} />
const Emphasized = (props) => <em {...props} />
const Strong = (props) => <strong {...props} />
const Delete = (props) => <del {...props} />
const Hairline = (props) => (
<ContainerSmall>
<hr {...props} />
</ContainerSmall>
)
const Link = (props) => <a {...props} />
const Image = (props) => <img {...props} />
/* eslint-enable */

const components = {
p: Paragraph,
h1: Headline1,
h2: Headline2,
h3: Headline3,
h4: Headline4,
h5: Headline5,
h6: Headline6,
thematicBreak: ThematicBreak,
blockquote: Blockquote,
ul: UnorderedList,
ol: OrderedList,
li: ListElement,
table: Table,
tr: TableRow,
td: TableCell,
pre: PreformattedCode,
code: InlineCode,
em: Emphasized,
strong: Strong,
delete: Delete,
// inlineCode: DDDDDD, // ??????
hr: Hairline,
a: Link,
img: Image,
}

exports.components = components
4 changes: 0 additions & 4 deletions metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ module.exports = {
name: 'Writings',
link: '/writings',
},
{
name: 'Changelog',
link: '/changelog',
},
],
socialLinks: [
{
Expand Down
Loading

0 comments on commit e4fdc15

Please sign in to comment.