Skip to content

Commit

Permalink
Initial commit from gatsby: (https://github.com/juliettepretot/gatsby…
Browse files Browse the repository at this point in the history
  • Loading branch information
ericcheatham committed Oct 30, 2019
0 parents commit a7b3a49
Show file tree
Hide file tree
Showing 19 changed files with 15,746 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"presets": [["babel-preset-gatsby"]],
"plugins": [["babel-plugin-root-import", { "rootPathSuffix": "src" }]]
}
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Project dependencies
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules
.cache/
.vscode/
# Build directory
public/
.DS_Store
yarn-error.log
19 changes: 19 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## Tech Stack 🥞

##### Linting & Formatting

The code is formatted (prettier), linted & type-checked using commit hooks.

##### Data

Content is stored in markdown files.

##### Styling

Styling is set up using Styled Components.

---

## License 🔓

MIT. :)
29 changes: 29 additions & 0 deletions gatsby-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'use strict'

module.exports = {
siteMetadata: {
title: 'Juliette Pretot',
description: 'Gatsby TypeScript Skeleton Starter',
siteUrl: 'https://juliette.sh',
author: {
name: 'Juliette Pretot',
url: 'https://juliette.sh',
email: '[email protected]'
}
},
plugins: [
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'src',
path: `${__dirname}/src`
}
},
'gatsby-transformer-remark',
'gatsby-plugin-styled-components',
'gatsby-plugin-typescript',
'gatsby-plugin-react-helmet',
'gatsby-plugin-catch-links',
'gatsby-plugin-offline'
]
}
71 changes: 71 additions & 0 deletions gatsby-node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
'use strict'

/*
Configure Gatsby to create pages from markdown files in ./src/markdownPages
*/

const pathUtil = require('path')
const { createFilePath } = require('gatsby-source-filesystem')

const MARKDOWN_PAGE_TEMPLATE = './src/components/MarkdownPage/index.tsx'

exports.onCreateNode = ({ node, actions, getNode }) => {
if (node.internal.type === 'MarkdownRemark') {
const filePath = createFilePath({ node, getNode })
const slug = filePath.startsWith('/pages') ? filePath.replace('/pages', '/') : ''

actions.createNodeField({
node,
name: 'slug',
value: slug
})

actions.createNodeField({
node,
name: 'isPage',
value: !!slug
})
}
}

exports.createPages = async ({ graphql, actions }) => {
const { createPage } = actions

const allMarkdown = await graphql(`
{
allMarkdownRemark(limit: 1000) {
edges {
node {
fields {
isPage
slug
}
}
}
}
}
`)

if (allMarkdown.errors) {
console.error(allMarkdown.errors)
throw new Error(allMarkdown.errors)
}

allMarkdown.data.allMarkdownRemark.edges
.filter(({ node }) => !!node.fields.isPage)
.forEach(({ node }) => {
const { slug } = node.fields

createPage({
path: slug,
component: pathUtil.resolve(MARKDOWN_PAGE_TEMPLATE),
context: {
// Data passed to context is available in page queries as GraphQL
// variables.
slug
}
})
})
}
Loading

0 comments on commit a7b3a49

Please sign in to comment.