Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix route -> parent template matching #230

Merged
merged 1 commit into from Apr 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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