Skip to content
Permalink
Browse files

MDX WIP

  • Loading branch information...
prichey committed Mar 4, 2019
1 parent d347d89 commit a8ce453816815a98fcd15965db392d0044506cae
Showing with 1,394 additions and 261 deletions.
  1. +56 −5 gatsby-config.js
  2. +89 −37 gatsby-node.js
  3. +588 −0 package-lock.json
  4. +3 −0 package.json
  5. +1 −0 src/components/Layout.js
  6. +25 −0 src/components/LayoutDelegator.js
  7. +70 −0 src/components/PostLayout.js
  8. +56 −0 src/components/ProjectLayout.js
  9. +3 −29 src/components/TextPostBody.js
  10. +5 −3 src/components/ZoomImage.js
  11. 0 src/{pages/blog → content/posts}/2017/index.md
  12. BIN src/{pages/blog → content/posts}/2018/century-complete-zoom.jpg
  13. BIN src/{pages/blog → content/posts}/2018/century-complete.jpg
  14. BIN src/{pages/blog → content/posts}/2018/end-zoom.jpg
  15. BIN src/{pages/blog → content/posts}/2018/end.jpg
  16. +59 −50 src/{pages/blog/2018/index.md → content/posts/2018/index.mdx}
  17. BIN src/{pages/blog → content/posts}/2018/plant-in-rental-car-zoom.jpg
  18. BIN src/{pages/blog → content/posts}/2018/plant-in-rental-car.jpg
  19. BIN src/{pages/blog → content/posts}/2018/reservoir-zoom.jpg
  20. BIN src/{pages/blog → content/posts}/2018/reservoir.jpg
  21. 0 src/{pages/blog → content/posts}/ar-vuforia-unity/index.md
  22. 0 src/{pages/blog → content/posts}/lessons-in-stealing-my-boss-voice/index.md
  23. BIN src/{pages/blog → content/posts}/lessons-in-stealing-my-boss-voice/jasmine-zoom.jpg
  24. BIN src/{pages/blog → content/posts}/lessons-in-stealing-my-boss-voice/jasmine.jpg
  25. BIN src/{pages/blog → content/posts}/lessons-in-stealing-my-boss-voice/jeff-zoom.jpg
  26. BIN src/{pages/blog → content/posts}/lessons-in-stealing-my-boss-voice/jeff.jpg
  27. +14 −0 src/content/posts/mdx/index.mdx
  28. 0 src/{pages/blog → content/posts}/of-video-loops/index.md
  29. 0 src/{pages/blog → content/posts}/pitchfork-proxies-jet/index.md
  30. BIN src/{pages/blog → content/posts}/pitchfork-proxies-jet/jet.jpg
  31. BIN src/{pages/blog → content/posts}/pitchfork-proxies-jet/shine-on-zoom.jpg
  32. BIN src/{pages/blog → content/posts}/pitchfork-proxies-jet/shine-on.jpg
  33. 0 src/{pages/blog → content/posts}/react-in-markdown/index.md
  34. BIN src/{pages/blog → content/posts}/react-in-markdown/lake-22-zoom.jpg
  35. BIN src/{pages/blog → content/posts}/react-in-markdown/lake-22.jpg
  36. BIN src/{pages/blog → content/posts}/react-in-markdown/mind-blown.gif
  37. BIN src/{pages/blog → content/posts}/react-rust-wasm/alert-zoom.jpg
  38. BIN src/{pages/blog → content/posts}/react-rust-wasm/alert.jpg
  39. BIN src/{pages/blog → content/posts}/react-rust-wasm/click-zoom.jpg
  40. BIN src/{pages/blog → content/posts}/react-rust-wasm/click.jpg
  41. 0 src/{pages/blog → content/posts}/react-rust-wasm/index.md
  42. BIN src/{pages/blog → content/posts}/react-rust-wasm/load-zoom.jpg
  43. BIN src/{pages/blog → content/posts}/react-rust-wasm/load.jpg
  44. 0 src/{pages/blog → content/posts}/things-i-didnt-post-to-instagram-2018/index.md
  45. 0 src/{pages → content}/projects/personal/bronnerbot/index.md
  46. 0 src/{pages → content}/projects/personal/e29da4/index.md
  47. +1 −1 src/{pages → content}/projects/personal/fredthoughts-bot/index.md
  48. 0 src/{pages → content}/projects/personal/gbmf/index.md
  49. 0 src/{pages → content}/projects/personal/menemnesa/index.md
  50. 0 src/{pages → content}/projects/personal/p4ktldr/index.md
  51. BIN src/{pages → content}/projects/personal/p4ktldr/p4ktldr-wilco-zoom.jpg
  52. BIN src/{pages → content}/projects/personal/p4ktldr/p4ktldr-wilco.jpg
  53. BIN src/{pages → content}/projects/personal/p4ktldr/p4ktldr-zoom.jpg
  54. BIN src/{pages → content}/projects/personal/p4ktldr/p4ktldr.jpg
  55. BIN src/{pages → content}/projects/personal/p4ktldr/pitchfork-wilco-zoom.jpg
  56. BIN src/{pages → content}/projects/personal/p4ktldr/pitchfork-wilco.jpg
  57. 0 src/{pages → content}/projects/personal/pizza-church/index.md
  58. BIN src/{pages → content}/projects/personal/pizza-church/pizza-church-zoom.jpg
  59. BIN src/{pages → content}/projects/personal/pizza-church/pizza-church.jpg
  60. 0 src/{pages → content}/projects/personal/roadkillbot/index.md
  61. BIN src/{pages → content}/projects/personal/rotten-trumpatoes/index-zoom.jpg
  62. BIN src/{pages → content}/projects/personal/rotten-trumpatoes/index.jpg
  63. 0 src/{pages → content}/projects/personal/rotten-trumpatoes/index.md
  64. BIN src/{pages → content}/projects/personal/rotten-trumpatoes/movies-zoom.jpg
  65. BIN src/{pages → content}/projects/personal/rotten-trumpatoes/movies.jpg
  66. BIN src/{pages → content}/projects/personal/rotten-trumpatoes/scrape-zoom.jpg
  67. BIN src/{pages → content}/projects/personal/rotten-trumpatoes/scrape.jpg
  68. 0 src/{pages → content}/projects/personal/they-linkedin/index.md
  69. BIN src/{pages → content}/projects/personal/they-linkedin/screenshot-zoom.jpg
  70. BIN src/{pages → content}/projects/personal/they-linkedin/screenshot.jpg
  71. BIN src/{pages → content}/projects/personal/they-linkedin/screenshot.png
  72. BIN src/{pages → content}/projects/professional/canizen/doors.gif
  73. 0 src/{pages → content}/projects/professional/canizen/index.md
  74. BIN src/{pages → content}/projects/professional/carmen/animation.gif
  75. 0 src/{pages → content}/projects/professional/carmen/index.md
  76. BIN src/{pages → content}/projects/professional/carmen/map-zoom.jpg
  77. BIN src/{pages → content}/projects/professional/carmen/map.jpg
  78. BIN src/{pages → content}/projects/professional/color-composer/canvas-zoom.jpg
  79. BIN src/{pages → content}/projects/professional/color-composer/canvas.jpg
  80. 0 src/{pages → content}/projects/professional/color-composer/index.md
  81. BIN src/{pages → content}/projects/professional/color-composer/static-zoom.jpg
  82. BIN src/{pages → content}/projects/professional/color-composer/static.jpg
  83. BIN src/{pages → content}/projects/professional/color-composer/static.png
  84. +0 −5 src/{pages → content}/projects/professional/mapkins-machine/index.md
  85. BIN src/{pages → content}/projects/professional/mapkins-machine/internals.jpg
  86. BIN src/{pages → content}/projects/professional/mapkins-machine/mapkins-machine-zoom.jpg
  87. BIN src/{pages → content}/projects/professional/mapkins-machine/mapkins-machine.jpg
  88. BIN src/{pages → content}/projects/professional/roshambot/hand-zoom.jpg
  89. BIN src/{pages → content}/projects/professional/roshambot/hand.jpeg
  90. BIN src/{pages → content}/projects/professional/roshambot/hand.jpg
  91. +0 −2 src/{pages → content}/projects/professional/roshambot/index.md
  92. BIN src/{pages → content}/projects/professional/roshambot/pedestal-zoom.jpg
  93. BIN src/{pages → content}/projects/professional/roshambot/pedestal.jpeg
  94. BIN src/{pages → content}/projects/professional/roshambot/pedestal.jpg
  95. +0 −1 src/pages/404.md
  96. +3 −2 src/pages/blog.js
  97. +0 −57 src/pages/blog/google-cloud-client-transcription/index.md
  98. +344 −0 src/pages/mdx.mdx
  99. +29 −5 src/pages/projects.js
  100. +0 −11 src/pages/projects/professional/dice-chatbot/index.md
  101. +0 −11 src/pages/projects/professional/millers-ale-house/index.md
  102. +0 −11 src/pages/projects/professional/noodles-and-co/index.md
  103. +18 −19 src/templates/post.js
  104. +30 −12 src/templates/project.js
@@ -9,10 +9,10 @@ module.exports = {
resolve: 'gatsby-transformer-remark',
options: {
plugins: [
{
resolve: 'gatsby-remark-component',
options: { components: ['zoom-image', 'hidden', 'countup'] }
},
// {
// resolve: 'gatsby-remark-component',
// options: { components: ['zoom-image', 'hidden', 'countup'] }
// },
{
resolve: 'gatsby-remark-autolink-headers'
},
@@ -50,6 +50,34 @@ module.exports = {
path: `${__dirname}/src/pages/`
}
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'posts',
path: `${__dirname}/src/content/posts`
}
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'projects',
path: `${__dirname}/src/content/projects`
}
},
// {
// resolve: 'gatsby-source-filesystem',
// options: {
// name: 'posts',
// path: `${__dirname}/src/pages/blog`
// }
// },
// {
// resolve: 'gatsby-source-filesystem',
// options: {
// name: 'projects',
// path: `${__dirname}/src/pages/projects`
// }
// },
{
resolve: 'gatsby-plugin-nprogress',
options: {
@@ -62,6 +90,29 @@ module.exports = {
trackingId: 'UA-70108869-1'
}
},
'gatsby-plugin-twitter'
'gatsby-plugin-twitter',
{
resolve: `gatsby-mdx`,
options: {
defaultLayouts: {
// projects: require.resolve('./src/components/ProjectLayout.js'),
// posts: require.resolve('./src/components/PostLayout.js'),
default: require.resolve('./src/components/PostLayout.js')
},
extensions: ['.md', '.mdx'],
gatsbyRemarkPlugins: [
{ resolve: 'gatsby-remark-autolink-headers' },
{ resolve: 'gatsby-remark-prismjs', options: {} },
{ resolve: 'gatsby-remark-smartypants' }
// {
// resolve: 'gatsby-remark-copy-linked-files',
// options: {
// ignoreFileExtensions: []
// }
// }
]
// mdPlugins: [require('gatsby-remark-prismjs')]
}
}
]
};
@@ -3,46 +3,88 @@ const { createFilePath } = require(`gatsby-source-filesystem`);

exports.onCreateNode = ({ node, getNode, actions }) => {
const { createNodeField } = actions;
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
}
try {
if (node.internal.type === 'Mdx') {
const fileNode = getNode(node.parent);
const { sourceInstanceName } = fileNode;

let type = 'page';
switch (dirSplit[0]) {
case 'projects':
type = 'project';
break;
case 'blog':
type = 'post';
break;
}
switch (sourceInstanceName) {
case 'projects':
const slug = createFilePath({
node,
getNode
});

createNodeField({
node,
name: 'type',
value: type
});
createNodeField({
node,
name: 'slug',
value: `/${sourceInstanceName}${slug}`
});

if (type === 'project') {
if (dirSplit.length > 1) {
createNodeField({
node,
name: 'projectType',
value: dirSplit[1]
});
} else {
throw new Error('each project needs a type');
// if (type === 'project') {
// if (dirSplit.length > 1) {
// createNodeField({
// node,
// name: 'projectType',
// value: dirSplit[1]
// });
// } else {
// throw new Error('each project needs a type');
// }
// }
break;
case 'posts':
const slug = createFilePath({
node,
getNode
});

createNodeField({
node,
name: 'slug',
value: `/blog${slug}`
});
case 'pages':
default:
const slug = createFilePath({
node,
getNode,
basePath: 'pages'
});

createNodeField({
node,
name: 'slug',
value: slug
});
break;
}

// 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
// }
// console.log({ dirSplit });
//
// let type = 'page';
// switch (dirSplit[0]) {
// case 'projects':
// type = 'project';
// break;
// case 'posts':
// type = 'post';
// break;
// }
//
createNodeField({
node,
name: 'type',
value: sourceInstanceName
});
}
} catch (e) {
console.log({ e });
}
};

@@ -52,7 +94,7 @@ exports.createPages = ({ graphql, actions }) => {
return new Promise((resolve, reject) => {
graphql(`
{
allMarkdownRemark {
allMdx {
edges {
node {
fields {
@@ -64,17 +106,27 @@ exports.createPages = ({ graphql, actions }) => {
}
}
`).then(result => {
result.data.allMarkdownRemark.edges.map(({ node }) => {
if (result.errors) {
console.log('shit');
console.error(result.errors);
reject(result.errors);
}

result.data.allMdx.edges.forEach(({ node }) => {
console.log({ slug: node.fields.slug });
const templatePath =
node.fields.type === 'project'
node.fields.type === 'projects'
? './src/templates/project.js'
: './src/templates/post.js';

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
// frontmatter: node.frontmatter,
// html: node.html
}
});
});

0 comments on commit a8ce453

Please sign in to comment.
You can’t perform that action at this time.