Skip to content

Commit 8087aeb

Browse files
committed
Merge pull request #165 from gatsbyjs/remove-underscore
Remove underscore and replace with Lodash
2 parents d13cf07 + 486bd29 commit 8087aeb

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

lib/loaders/markdown-loader/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import frontMatter from 'front-matter'
22
import markdownIt from 'markdown-it'
33
import hljs from 'highlight.js'
4-
import _ from 'underscore'
4+
import objectAssign from 'object-assign'
55

66
const highlight = (str, lang) => {
77
if ((lang !== null) && hljs.getLanguage(lang)) {
@@ -31,7 +31,7 @@ module.exports = function (content) {
3131
this.cacheable()
3232
const meta = frontMatter(content)
3333
body = md.render(meta.body)
34-
const result = _.extend({}, meta.attributes, {
34+
const result = objectAssign({}, meta.attributes, {
3535
body,
3636
})
3737
this.value = result

lib/utils/develop.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import ReactDOMServer from 'react-dom/server'
66
import webpack from 'webpack'
77
import Negotiator from 'negotiator'
88
import parsePath from 'parse-filepath'
9-
import _ from 'underscore'
9+
import find from 'lodash/find'
1010
import webpackRequire from 'webpack-require'
1111
import fs from 'fs'
1212
import toml from 'toml'
@@ -102,7 +102,7 @@ module.exports = (program) => {
102102
} else {
103103
// Rewrite path to match disk path.
104104
const parsed = parsePath(request.path)
105-
const page = _.find(pages, (p) => p.path === (`${parsed.dirname}/`))
105+
const page = find(pages, (p) => p.path === (`${parsed.dirname}/`))
106106

107107
if (page) {
108108
request.setUrl(`/${parsePath(page.requirePath).dirname}/${parsed.basename}`)

lib/utils/glob-pages.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import slash from 'slash'
55
import fs from 'fs'
66
import frontMatter from 'front-matter'
77
import htmlFrontMatter from 'html-frontmatter'
8-
import _ from 'underscore'
8+
import objectAssign from 'object-assign'
99
const debug = require('debug')('gatsby:glob')
1010

1111
module.exports = (directory, callback) => {
@@ -39,11 +39,11 @@ module.exports = (directory, callback) => {
3939
let data
4040
if (ext === 'md') {
4141
const rawData = frontMatter(fs.readFileSync(page, 'utf-8'))
42-
data = _.extend({}, rawData.attributes)
42+
data = objectAssign({}, rawData.attributes)
4343
pageData.data = data
4444
} else if (ext === 'html') {
4545
const html = fs.readFileSync(page, 'utf-8')
46-
data = _.extend({}, htmlFrontMatter(html), { body: html })
46+
data = objectAssign({}, htmlFrontMatter(html), { body: html })
4747
pageData.data = data
4848
} else {
4949
data = {}

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@
6868
"toml": "^2.2.2",
6969
"toml-loader": "^1.0.0",
7070
"typography": "^0.7.0",
71-
"underscore": "^1.8.3",
7271
"underscore.string": "^3.2.3",
7372
"webpack": "^1.12.13",
7473
"webpack-configurator": "^0.3.0",

0 commit comments

Comments
 (0)