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

add createLayout api + multiple layouts + layout queries #1503

Merged
merged 43 commits into from
Aug 8, 2017
Merged
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
3aaf1ad
add createlayout api
Jul 13, 2017
96d33f1
fix props passing
Jul 14, 2017
c1f1f91
load async components in production
Jul 16, 2017
0c06c08
change layout.path -> layout.name
Jul 16, 2017
625f4da
clean up
Jul 16, 2017
be88f47
clean up
Jul 16, 2017
10a75ef
fix static entry
Jul 16, 2017
2da92e1
PR comments
Jul 17, 2017
af05d40
spitting out data
Jul 18, 2017
77622d2
spitting out data
Jul 18, 2017
7807e8d
queries in layouts
Jul 18, 2017
2a6a492
change page-data-deps -> component-data-deps
Jul 19, 2017
eb2e2c8
change page-data-deps -> component-data-deps
Jul 19, 2017
37e6b15
layoutComponentChunkName -> generateComponentChunkName
Jul 19, 2017
5543eee
pathChunkName > generatePathChunkName
Jul 19, 2017
4f317f7
createPageComponent -> createComponent
Jul 19, 2017
85c1e8c
add onCreateComponent and remove createComponent action
Jul 19, 2017
2ba2356
using remark is now working
Jul 19, 2017
0cbbb46
mostly working
Jul 19, 2017
3ce3470
watch queries kinda
Jul 19, 2017
ac6c6db
watching is broken
Jul 19, 2017
f4ff4ce
watch is working
Jul 21, 2017
6b5a518
rm multi-layout example + add layout context
Jul 22, 2017
8dcdc9f
prod build working
Jul 22, 2017
edcb49f
add redux tests
Jul 22, 2017
d7fc93c
tests passing
Jul 22, 2017
6690f79
format
Jul 22, 2017
6653a0c
rm console.logs
Jul 22, 2017
f32e781
allow page.layout === null
Jul 25, 2017
35a7093
PR amends
Jul 27, 2017
f520828
format
Jul 28, 2017
4469a87
Merge branch 'master' into multi-layouts
KyleAMathews Aug 1, 2017
7ee3bf8
fix syntax err
Aug 1, 2017
0317f6d
fix no layout case in prod
Aug 1, 2017
197435f
Merge branch 'master' into multi-layouts
KyleAMathews Aug 7, 2017
fbc241d
Updates to Layout PR
KyleAMathews Aug 8, 2017
1bb6a25
Merge branch 'master' into multi-layouts
KyleAMathews Aug 8, 2017
58832d0
Fix tests
KyleAMathews Aug 8, 2017
35b1a57
Fix comments
KyleAMathews Aug 8, 2017
750d273
Layout code + data should be one bundle as always loaded together
KyleAMathews Aug 8, 2017
724ff41
Restore letting layout override what props passed to component
KyleAMathews Aug 8, 2017
b679f80
Move layout rendering to a stateful layout renderer similar to the co…
KyleAMathews Aug 8, 2017
08bd0f3
update snapshots
KyleAMathews Aug 8, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix tests
KyleAMathews committed Aug 8, 2017
commit 58832d09a0484aae083eb14f2eb5d2316db4a303
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const _ = require(`lodash`)
const glob = require(`glob`)
const fs = require(`fs-extra`)

const { store, emitter } = require(`../../redux/`)
@@ -12,7 +11,7 @@ const getLayoutById = layouts => id => layouts.find(l => l.id === id)
// Write out pages information.
const writePages = async () => {
writtenOnce = true
let { program, config, pages, layouts } = store.getState()
let { program, pages, layouts } = store.getState()
// Write out pages.json
const pagesData = pages.reduce(
(mem, { path, matchPath, componentChunkName, layout, jsonName }) => {
@@ -53,8 +52,6 @@ const writePages = async () => {
json.push({ path: p.path, jsonName: p.jsonName })
})

// Add the default layout if it exists.
let defaultLayoutExists = false
pageLayouts = _.uniq(pageLayouts)
components = _.uniqBy(components, c => c.componentChunkName)

24 changes: 5 additions & 19 deletions packages/gatsby/src/redux/__tests__/__snapshots__/layouts.js.snap
Original file line number Diff line number Diff line change
@@ -82,29 +82,15 @@ Array [
"pluginCreator___NODE": "Plugin test",
},
Object {
"component": "/whatever/index.js",
"componentChunkName": "component---whatever-index-js",
"component": "/whatever/pizza.js",
"componentChunkName": "component---whatever-pizza-js",
"context": Object {},
"id": "indexpizza/",
"internalComponentName": "Component-layout-Indexpizza",
"jsonName": "layout-indexpizza.json",
"id": "pizza",
"internalComponentName": "Component-layout-Pizza",
"jsonName": "layout-pizza.json",
"pluginCreator___NODE": "Plugin test",
},
]
`;

exports[`Add layouts allows you to delete ids 1`] = `Array []`;

exports[`Add layouts allows you to update existing layouts (based on id) 1`] = `
Array [
Object {
"component": "/whatever2/index.js",
"componentChunkName": "component---whatever-2-index-js",
"context": Object {},
"id": "index",
"internalComponentName": "Component-layout-Index",
"jsonName": "layout-index.json",
"pluginCreator___NODE": "Plugin test",
},
]
`;
31 changes: 1 addition & 30 deletions packages/gatsby/src/redux/__tests__/layouts.js
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@ describe(`Add layouts`, () => {
it(`allows you to add layouts`, () => {
const action = actions.createLayout(
{
id: `index`,
component: `/whatever/index.js`,
},
{ name: `test` }
@@ -18,7 +17,6 @@ describe(`Add layouts`, () => {
it(`allows you to add layout with context`, () => {
const action = actions.createLayout(
{
id: `index`,
component: `/whatever/index.js`,
context: {
title: `layout title`,
@@ -34,15 +32,13 @@ describe(`Add layouts`, () => {
it(`allows you to add multiple layouts`, () => {
const action = actions.createLayout(
{
id: `index`,
component: `/whatever/index.js`,
},
{ name: `test` }
)
const action2 = actions.createLayout(
{
id: `indexpizza/`,
component: `/whatever/index.js`,
component: `/whatever/pizza.js`,
},
{ name: `test` }
)
@@ -52,34 +48,9 @@ describe(`Add layouts`, () => {
expect(state.length).toEqual(2)
})

it(`allows you to update existing layouts (based on id)`, () => {
const action = actions.createLayout(
{
id: `index`,
component: `/whatever/index.js`,
},
{ name: `test` }
)

// Change the component
const action2 = actions.createLayout(
{
id: `index`,
component: `/whatever2/index.js`,
},
{ name: `test` }
)

let state = reducer(undefined, action)
state = reducer(state, action2)
expect(state).toMatchSnapshot()
expect(state.length).toEqual(1)
})

it(`allows you to delete ids`, () => {
const action = actions.createLayout(
{
id: `index`,
component: `/whatever/index.js`,
},
{ name: `test` }