Skip to content

Commit

Permalink
Fix route -> parent template matching (#230)
Browse files Browse the repository at this point in the history
This commit also removes the need for underscore.string
  • Loading branch information
Berkeley Martinez authored and KyleAMathews committed Apr 9, 2016
1 parent 2856acc commit 3ad3a7a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
7 changes: 3 additions & 4 deletions lib/isomorphic/create-routes.js
@@ -1,7 +1,6 @@
import filter from 'lodash/filter'
import sortBy from 'lodash/sortBy'
import last from 'lodash/last'
import includes from 'underscore.string/include'
import { prefixLink } from './gatsby-helpers'

module.exports = (files, pagesReq) => {
Expand Down Expand Up @@ -42,7 +41,7 @@ module.exports = (files, pagesReq) => {
// with it.
templatesWithoutRoot.forEach((templateFile) => {
let parentTemplates = filter(templatesWithoutRoot, (template) =>
includes(templateFile.requirePath, template.file.dirname)
templateFile.requirePath.indexOf(template.file.dirname) === 0
)
// Sort parent templates by directory length. In cases
// where a template has multiple parents
Expand Down Expand Up @@ -122,7 +121,7 @@ module.exports = (files, pagesReq) => {

// Determine parent template for page.
const parentTemplates = filter(templatesWithoutRoot, (templateFile) =>
includes(page.requirePath, templateFile.file.dirname)
page.requirePath.indexOf(templateFile.file.dirname) === 0
)

const sortedParentTemplates = sortBy(parentTemplates, (route) => route.file.dirname.length)
Expand Down Expand Up @@ -159,7 +158,7 @@ module.exports = (files, pagesReq) => {
})
}

if (includes(page.path, '/404')) {
if (page.path.indexOf('/404') !== -1) {
notFound = {
path: '*',
component: handler,
Expand Down
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -72,7 +72,6 @@
"toml": "^2.2.2",
"toml-loader": "^1.0.0",
"typography": "^0.7.0",
"underscore.string": "^3.2.3",
"url-loader": "^0.5.7",
"webpack": "^1.12.13",
"webpack-configurator": "^0.3.0",
Expand Down

0 comments on commit 3ad3a7a

Please sign in to comment.