diff --git a/.babelrc b/.babelrc new file mode 100644 index 000000000..cedec0b9e --- /dev/null +++ b/.babelrc @@ -0,0 +1,3 @@ +{ + "plugins": ["lodash"] +} \ No newline at end of file diff --git a/gatsby-node.js b/gatsby-node.js index 2aedf70b5..54ed190b2 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -1,4 +1,5 @@ const path = require('path'); +const webpackLodashPlugin = require('lodash-webpack-plugin'); exports.onCreateNode = ({ node, boundActionCreators, getNode }) => { const { createNodeField } = boundActionCreators; @@ -22,7 +23,7 @@ exports.createPages = ({ graphql, boundActionCreators }) => { const { createPage } = boundActionCreators; return new Promise((resolve, reject) => { - const blogPost = path.resolve('src/templates/post.jsx'); + const postPage = path.resolve('src/templates/post.jsx'); resolve( graphql( ` @@ -30,6 +31,9 @@ exports.createPages = ({ graphql, boundActionCreators }) => { allMarkdownRemark { edges { node { + frontmatter { + tags + } fields { slug } @@ -48,7 +52,7 @@ exports.createPages = ({ graphql, boundActionCreators }) => { result.data.allMarkdownRemark.edges.forEach((edge) => { createPage({ path: edge.node.fields.slug, - component: blogPost, + component: postPage, context: { slug: edge.node.fields.slug, }, @@ -58,3 +62,10 @@ exports.createPages = ({ graphql, boundActionCreators }) => { ); }); }; + +exports.modifyWebpackConfig = ({ config, stage }) => { + if (stage === 'build-javascript') { + config.plugin('Lodash', webpackLodashPlugin, null); + } +} +; diff --git a/package.json b/package.json index 696bf1876..e7852d4dd 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "version": "0.1.7", "author": "Ruben Harutyunyan", "dependencies": { + "babel-plugin-lodash": "^3.2.11", "font-awesome": "^4.7.0", "gatsby": "^1.0.2", "gatsby-link": "^1.0.1", @@ -19,6 +20,8 @@ "gatsby-remark-smartypants": "^1.0.1", "gatsby-source-filesystem": "^1.0.1", "gatsby-transformer-remark": "^1.0.1", + "lodash": "^4.17.4", + "lodash-webpack-plugin": "^0.11.4", "react-disqus-comments": "^1.0.3", "react-md": "^1.1.0-alpha-5" }, diff --git a/yarn.lock b/yarn.lock index c09913aae..d62d20d93 100644 --- a/yarn.lock +++ b/yarn.lock @@ -559,6 +559,13 @@ babel-plugin-check-es2015-constants@^6.22.0: dependencies: babel-runtime "^6.22.0" +babel-plugin-lodash@^3.2.11: + version "3.2.11" + resolved "https://registry.yarnpkg.com/babel-plugin-lodash/-/babel-plugin-lodash-3.2.11.tgz#21c8fdec9fe1835efaa737873e3902bdd66d5701" + dependencies: + glob "^7.1.1" + lodash "^4.17.2" + babel-plugin-syntax-async-functions@^6.8.0: version "6.13.0" resolved "https://registry.yarnpkg.com/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz#cad9cad1191b5ad634bf30ae0872391e0647be95" @@ -5096,6 +5103,12 @@ lodash-id@^0.14.0: version "0.14.0" resolved "https://registry.yarnpkg.com/lodash-id/-/lodash-id-0.14.0.tgz#baf48934e543a1b5d6346f8c84698b1a8c803896" +lodash-webpack-plugin@^0.11.4: + version "0.11.4" + resolved "https://registry.yarnpkg.com/lodash-webpack-plugin/-/lodash-webpack-plugin-0.11.4.tgz#6c3ecba3d4b8d24b53940b63542715c5ed3c4ac5" + dependencies: + lodash "^4.17.4" + lodash._basecopy@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz#8da0e6a876cf344c0ad8a54882111dd3c5c7ca36"