diff --git a/.babel-preset.js b/.babel-preset.js index 8d4d2d8d215cb..48a144295bffd 100644 --- a/.babel-preset.js +++ b/.babel-preset.js @@ -42,6 +42,7 @@ function preset(context, options = {}) { ], plugins: [ r("@babel/plugin-proposal-class-properties"), + r("@babel/plugin-proposal-optional-chaining"), [ r("@babel/plugin-transform-runtime"), { diff --git a/Breaking Changes.md b/Breaking Changes.md index a24efff4145a6..e14de8bef97b9 100644 --- a/Breaking Changes.md +++ b/Breaking Changes.md @@ -5,4 +5,4 @@ * Remove explicit polyfill and use the new builtins: usage support in babel 7. * Changed `modifyBabelrc` to `onCreateBabelConfig` * Changed `modifyWebpackConfig` to `onCreateWebpackConfig` -* inlining css changed — remove it as done automatically by core now. +* inlining css changed — remove it from any custom html.js as done automatically by core now. diff --git a/docs/docs/api-specification.md b/docs/docs/api-specification.md index 398dfdf725770..c917cbfa71333 100644 --- a/docs/docs/api-specification.md +++ b/docs/docs/api-specification.md @@ -56,9 +56,9 @@ See ## Concepts * _Page_ — a site page with a pathname, a template component, and optional - graphql query and layout component + graphql query. * _Page Component_ — React.js component that renders a page and can optionally - specify a layout component and a graphql query + specify a graphql query * _Component extensions_ — extensions that are resolvable as components. `.js` and `.jsx` are supported by core. But plugins can add support for other compile-to-js languages. diff --git a/docs/docs/building-with-components.md b/docs/docs/building-with-components.md index d1109cff86714..8444cb5385afc 100644 --- a/docs/docs/building-with-components.md +++ b/docs/docs/building-with-components.md @@ -40,10 +40,7 @@ A basic directory structure of a project might look like this:    │      └── 01-03-2017    │         └── index.md    ├── templates -    │ └── post.jsx - │ - └── layouts - └── index.jsx +    └── post.jsx ``` ### Page components @@ -117,31 +114,6 @@ export const pageQuery = graphql` `; ``` -### Layout components - -`src/layouts/index.jsx` (optional) wraps page components. You can use it for -portions of pages that are shared across pages like headers and footers. - -You can use the `location` prop to render conditionally based on the page -URL. - -Example: - -```jsx -import React from "react"; -import Navigation from "../components/Navigation/Navigation.jsx"; - -export default class Template extends React.Component { - render() { - if (this.props.location.pathname !== "/") { - return {this.props.children()}; - } else { - return this.props.children(); - } - } -} -``` - ### HTML component `src/html.jsx` is responsible for everything other than where Gatsby lives in diff --git a/docs/docs/creating-and-modifying-pages.md b/docs/docs/creating-and-modifying-pages.md index 50e39c7a908d3..a7b6974870caf 100644 --- a/docs/docs/creating-and-modifying-pages.md +++ b/docs/docs/creating-and-modifying-pages.md @@ -84,8 +84,6 @@ exports.createPages = ({ boundActionCreators, graphql }) => { createPage({ path, component: blogPostTemplate, - // If you have a layout component at src/layouts/blog-layout.js - layout: `blog-layout`, // In your blog post template's graphql query, you can use path // as a GraphQL variable to query for data from the markdown file. context: { @@ -133,33 +131,3 @@ exports.onCreatePage = ({ page, boundActionCreators }) => { }); }; ``` - -### Choosing the page layout - -By default, all pages will use the layout found at `/layouts/index.js`. - -You may wish to choose a custom layout for certain pages (such as removing -header and footer for landing pages). You can choose the layout component when -creating pages with the `createPage` action by adding a layout key to the page -object or modify pages created elsewhere using the `onCreatePage` API. All -components in the `/layouts/` directory are automatically available. - -```javascript -// Implement the Gatsby API “onCreatePage”. This is -// called after every page is created. -exports.onCreatePage = async ({ page, boundActionCreators }) => { - const { createPage } = boundActionCreators; - - return new Promise((resolve, reject) => { - if (page.path.match(/^\/landing-page/)) { - // It's assumed that `landingPage.js` exists in the `/layouts/` directory - page.layout = "landingPage"; - - // Update the page. - createPage(page); - } - - resolve(); - }); -}; -``` diff --git a/examples/client-only-paths/gatsby-config.js b/examples/client-only-paths/gatsby-config.js index 67d69843c1785..23f1cfbdf7078 100644 --- a/examples/client-only-paths/gatsby-config.js +++ b/examples/client-only-paths/gatsby-config.js @@ -4,11 +4,10 @@ module.exports = { }, plugins: [ { - resolve: `gatsby-plugin-google-analytics`, + resolve: `gatsby-plugin-typography`, options: { - trackingId: `UA-93349937-2`, + pathToConfigModule: `src/utils/typography`, }, }, - `gatsby-plugin-offline`, ], } diff --git a/examples/client-only-paths/package.json b/examples/client-only-paths/package.json index 12b79460531fa..84912315d7fd0 100644 --- a/examples/client-only-paths/package.json +++ b/examples/client-only-paths/package.json @@ -5,16 +5,16 @@ "version": "1.0.0", "author": "Kyle Mathews ", "dependencies": { - "gatsby": "latest", - "gatsby-plugin-google-analytics": "latest", - "gatsby-plugin-offline": "latest", - "gatsby-source-drupal": "latest", + "gatsby": "canary", + "gatsby-plugin-typography": "canary", "lodash": "^4.16.4", + "react": "^16.3.1", "react-addons-css-transition-group": "^15.5.2", - "react-typography": "^0.15.0", + "react-dom": "^16.3.1", + "react-typography": "^0.16.13", "slash": "^1.0.0", - "typography": "^0.15.8", - "typography-breakpoint-constants": "^0.14.0" + "typography": "^0.16.6", + "typography-breakpoint-constants": "^0.15.10" }, "keywords": [ "gatsby" @@ -25,4 +25,4 @@ "develop": "gatsby develop", "build": "gatsby build" } -} \ No newline at end of file +} diff --git a/examples/client-only-paths/src/html.js b/examples/client-only-paths/src/html.js deleted file mode 100644 index 432fc911a9a9b..0000000000000 --- a/examples/client-only-paths/src/html.js +++ /dev/null @@ -1,67 +0,0 @@ -import React, { Component } from "react" -import * as PropTypes from "prop-types" -import { TypographyStyle } from "react-typography" -import typography from "./utils/typography" - -let stylesStr -if (process.env.NODE_ENV === `production`) { - try { - stylesStr = require(`!raw-loader!../public/styles.css`) - } catch (e) { - console.log(e) - } -} - -const propTypes = { - headComponents: PropTypes.node.isRequired, - body: PropTypes.node.isRequired, - postBodyComponents: PropTypes.node.isRequired, -} - -class Html extends Component { - render() { - let css - if (process.env.NODE_ENV === `production`) { - css = ( -