From 486bd298a6a211d38d7e68f5509d4efa27c9073a Mon Sep 17 00:00:00 2001 From: Kyle Mathews Date: Mon, 29 Feb 2016 21:46:17 -0700 Subject: [PATCH] Remove underscore and replace with Lodash Fixes #138 --- lib/loaders/markdown-loader/index.js | 4 ++-- lib/utils/develop.js | 4 ++-- lib/utils/glob-pages.js | 6 +++--- package.json | 1 - 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/loaders/markdown-loader/index.js b/lib/loaders/markdown-loader/index.js index 6bf42851d688e..21ccc43f114a7 100644 --- a/lib/loaders/markdown-loader/index.js +++ b/lib/loaders/markdown-loader/index.js @@ -1,7 +1,7 @@ import frontMatter from 'front-matter' import markdownIt from 'markdown-it' import hljs from 'highlight.js' -import _ from 'underscore' +import objectAssign from 'object-assign' const highlight = (str, lang) => { if ((lang !== null) && hljs.getLanguage(lang)) { @@ -31,7 +31,7 @@ module.exports = function (content) { this.cacheable() const meta = frontMatter(content) body = md.render(meta.body) - const result = _.extend({}, meta.attributes, { + const result = objectAssign({}, meta.attributes, { body, }) this.value = result diff --git a/lib/utils/develop.js b/lib/utils/develop.js index aabe083e03715..b844f227230c4 100644 --- a/lib/utils/develop.js +++ b/lib/utils/develop.js @@ -6,7 +6,7 @@ import ReactDOMServer from 'react-dom/server' import webpack from 'webpack' import Negotiator from 'negotiator' import parsePath from 'parse-filepath' -import _ from 'underscore' +import find from 'lodash/find' import webpackRequire from 'webpack-require' import fs from 'fs' import toml from 'toml' @@ -102,7 +102,7 @@ module.exports = (program) => { } else { // Rewrite path to match disk path. const parsed = parsePath(request.path) - const page = _.find(pages, (p) => p.path === (`${parsed.dirname}/`)) + const page = find(pages, (p) => p.path === (`${parsed.dirname}/`)) if (page) { request.setUrl(`/${parsePath(page.requirePath).dirname}/${parsed.basename}`) diff --git a/lib/utils/glob-pages.js b/lib/utils/glob-pages.js index a60c827d3d771..5bb9ab432659c 100644 --- a/lib/utils/glob-pages.js +++ b/lib/utils/glob-pages.js @@ -5,7 +5,7 @@ import slash from 'slash' import fs from 'fs' import frontMatter from 'front-matter' import htmlFrontMatter from 'html-frontmatter' -import _ from 'underscore' +import objectAssign from 'object-assign' const debug = require('debug')('gatsby:glob') module.exports = (directory, callback) => { @@ -39,11 +39,11 @@ module.exports = (directory, callback) => { let data if (ext === 'md') { const rawData = frontMatter(fs.readFileSync(page, 'utf-8')) - data = _.extend({}, rawData.attributes) + data = objectAssign({}, rawData.attributes) pageData.data = data } else if (ext === 'html') { const html = fs.readFileSync(page, 'utf-8') - data = _.extend({}, htmlFrontMatter(html), { body: html }) + data = objectAssign({}, htmlFrontMatter(html), { body: html }) pageData.data = data } else { data = {} diff --git a/package.json b/package.json index 3a87c9477ac3f..4dd575417e5fb 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,6 @@ "toml": "^2.2.2", "toml-loader": "^1.0.0", "typography": "^0.7.0", - "underscore": "^1.8.3", "underscore.string": "^3.2.3", "webpack": "^1.12.13", "webpack-configurator": "^0.3.0",