-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🌟projects and blog posts now actually work
- Loading branch information
1 parent
6b66c7b
commit 73d795e
Showing
30 changed files
with
1,607 additions
and
447 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"title": "Blog", | ||
"about": "This is where I write things. Or at least it will be where I write things, as soon as I start writing things." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"title": "Projects", | ||
"about": "Here are some of the projects I have worked on and am proud enough of to publicise here." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,7 @@ | ||
/* eslint-disable import/prefer-default-export */ | ||
import './src/styles/global.scss'; | ||
import React from 'react'; | ||
import { CodeProvider } from './src/components/common/CodeContext'; | ||
|
||
// eslint-disable-next-line react/prop-types | ||
export const wrapRootElement = ({ element }) => <CodeProvider>{element}</CodeProvider>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
const path = require('path'); | ||
|
||
const { createFilePath } = require(`gatsby-source-filesystem`); | ||
|
||
exports.onCreateNode = ({ node, getNode, boundActionCreators }) => { | ||
const { createNodeField } = boundActionCreators; | ||
if (node.internal.type === `MarkdownRemark`) { | ||
const slug = createFilePath({ node, getNode, basePath: `pages` }); | ||
createNodeField({ | ||
node, | ||
name: 'slug', | ||
value: slug, | ||
}); | ||
|
||
const dirSplit = path.parse(slug).dir.split(path.sep); | ||
if (dirSplit.length > 0 && dirSplit[0] === '') { | ||
dirSplit.shift(); // because path starts with /, '' is always at position 0 | ||
} | ||
|
||
let type = 'page'; | ||
switch (dirSplit[0]) { | ||
case 'projects': | ||
type = 'project'; | ||
break; | ||
case 'blog': | ||
type = 'post'; | ||
break; | ||
} | ||
|
||
createNodeField({ | ||
node, | ||
name: 'type', | ||
value: type, | ||
}); | ||
} | ||
}; | ||
|
||
exports.createPages = ({ graphql, boundActionCreators }) => { | ||
const { createPage } = boundActionCreators; | ||
|
||
return new Promise((resolve, reject) => { | ||
graphql(` | ||
{ | ||
allMarkdownRemark { | ||
edges { | ||
node { | ||
fields { | ||
slug | ||
type | ||
} | ||
} | ||
} | ||
} | ||
} | ||
`).then(result => { | ||
result.data.allMarkdownRemark.edges.map(({ node }) => { | ||
const templatePath = | ||
node.fields.type === 'project' | ||
? './src/templates/project.jsx' | ||
: './src/templates/blogPost.jsx'; | ||
createPage({ | ||
path: node.fields.slug, | ||
component: path.resolve(templatePath), | ||
context: { | ||
// Data passed to context is available in page queries as GraphQL variables. | ||
slug: node.fields.slug, | ||
}, | ||
}); | ||
}); | ||
resolve(); | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
const defaultState = { | ||
language: 'java', | ||
changeLanguage: () => {}, | ||
}; | ||
|
||
const CodeContext = React.createContext(defaultState); | ||
|
||
class CodeProvider extends React.Component { | ||
state = { | ||
language: 'java', | ||
}; | ||
|
||
changeLanguage = language => { | ||
let newLanguage = ''; | ||
switch (language.toLowerCase()) { | ||
case 'javascript': | ||
newLanguage = 'javascript'; | ||
break; | ||
case 'react': | ||
newLanguage = 'javascript'; | ||
break; | ||
case 'python': | ||
newLanguage = 'python'; | ||
break; | ||
case 'java': | ||
newLanguage = 'java'; | ||
break; | ||
default: | ||
newLanguage = 'java'; | ||
} | ||
this.setState({ language: newLanguage }); | ||
}; | ||
|
||
render() { | ||
const { children } = this.props; | ||
const { language } = this.state; | ||
return ( | ||
<CodeContext.Provider | ||
value={{ | ||
language, | ||
changeLanguage: this.changeLanguage, | ||
}} | ||
> | ||
{children} | ||
</CodeContext.Provider> | ||
); | ||
} | ||
} | ||
|
||
CodeProvider.propTypes = { | ||
children: PropTypes.any.isRequired, | ||
}; | ||
|
||
export default CodeContext; | ||
|
||
export { CodeProvider }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import Me from '../me/me'; | ||
import './complexWrapper.scss'; | ||
|
||
const ComplexWrapper = ({ children }) => ( | ||
<div id={'content'}> | ||
<aside id={'content_left'}> | ||
<Me /> | ||
</aside> | ||
<section id={'main'}>{children}</section> | ||
</div> | ||
); | ||
|
||
ComplexWrapper.propTypes = { | ||
children: PropTypes.any.isRequired, | ||
}; | ||
|
||
export default ComplexWrapper; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#content { | ||
display: flex; | ||
position: relative; | ||
margin: 0; | ||
|
||
$leftWidth: 300px; | ||
|
||
letter-spacing: 0.15ch; | ||
|
||
@media (min-width: 750px) { | ||
#content_left { | ||
width: $leftWidth; | ||
position: fixed; | ||
z-index: 1; | ||
height: 100%; | ||
} | ||
#main { | ||
width: 100%; | ||
margin-top: 80px; | ||
margin-bottom: 50px; | ||
padding-left: $leftWidth; | ||
max-width: 800px; | ||
} | ||
} | ||
@media (max-width: 750px) { | ||
#content_left { | ||
display: none; | ||
} | ||
#main { | ||
width: 100%; | ||
margin-top: 80px; | ||
margin-bottom: 50px; | ||
padding: 0 40px; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#wrapper { | ||
// margin: 0 20px; | ||
height: 100vh; | ||
} |
Oops, something went wrong.