18 |
21 |
22 |
23 | )
24 | })}
25 |
26 | )
27 |
28 | const HomePage = ({ pageContext }) => {
29 | return (
30 |
34 | )
35 | }
36 |
37 | export default HomePage
38 |
--------------------------------------------------------------------------------
/src/core/catch-error.component.js:
--------------------------------------------------------------------------------
1 | import React from "react"
2 |
3 | /*
4 | * Used to help catch issues with invalid MDX in Netlify CMS
5 | * Netlify CMS Previews have some trouble with hooks, so
6 | * Use a class component here if possible
7 | */
8 | export class CatchError extends React.Component {
9 | constructor(props) {
10 | super(props)
11 | this.state = { hasError: false }
12 | }
13 |
14 | componentDidCatch(error, info) {
15 | // Display fallback UI
16 | this.setState({ hasError: true })
17 | // You can also log the error to an error reporting service
18 | console.warn(error, info)
19 | }
20 |
21 | render() {
22 | if (this.state.hasError) {
23 | // You can render any custom fallback UI
24 | return (
25 |
26 | Oops! Something went wrong. If you have edited this page recently,
27 | check your content and try again.
28 |
29 | )
30 | }
31 | return this.props.children
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/page-templates/cms-entry.template.js:
--------------------------------------------------------------------------------
1 | import React from "react"
2 |
3 | import HomePage from "./home-page.template"
4 | import DefaultPage from "./default-page.template"
5 | import NotFoundPage from "./not-found.template"
6 | import { AppLayout } from "../app-layout.component"
7 | import { safelyGetFrontMatter } from "../cms"
8 |
9 | // Extend this template map to allow your users to choose a page layout from the CMS
10 | // If you're only looking for how to specify a different template per content folder, see:
11 | // https://www.gatsbyjs.org/packages/gatsby-mdx/#installation
12 | const componentTemplateMap = {
13 | "home-page": HomePage,
14 | "hidden-page": NotFoundPage,
15 | }
16 |
17 | const CMSTemplate = props => {
18 | const { pageContext } = props
19 | const { templateKey } = safelyGetFrontMatter(pageContext)
20 | const Page = componentTemplateMap[templateKey]
21 | return (
22 |
23 | {Page ? : }
24 |
25 | )
26 | }
27 |
28 | export default CMSTemplate
29 |
--------------------------------------------------------------------------------
/src/components/image.js:
--------------------------------------------------------------------------------
1 | import React from "react"
2 | import { StaticQuery, graphql } from "gatsby"
3 | import Img from "gatsby-image"
4 |
5 | /*
6 | * This component is built using `gatsby-image` to automatically serve optimized
7 | * images with lazy loading and reduced file sizes. The image is loaded using a
8 | * `StaticQuery`, which allows us to load the image from directly within this
9 | * component, rather than having to pass the image data down from pages.
10 | *
11 | * For more information, see the docs:
12 | * - `gatsby-image`: https://gatsby.app/gatsby-image
13 | * - `StaticQuery`: https://gatsby.app/staticquery
14 | */
15 |
16 | const Image = () => (
17 | }
30 | />
31 | )
32 | export default Image
33 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 gatsbyjs
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/src/page-templates/default-page.template.js:
--------------------------------------------------------------------------------
1 | import React from "react"
2 | import { MDXProvider } from "@mdx-js/react"
3 |
4 | import {
5 | safelyGetFrontMatter,
6 | withFallback,
7 | CMS_COMPONENTS,
8 | CMS_SHORTCODES,
9 | } from "../cms"
10 | import { SEO, Heading } from "../components"
11 | import { RenderMarkdown } from "../core"
12 |
13 | export const DefaultPageTemplate = ({ title, body, children }) => {
14 | return (
15 |
16 |
17 | {title}
18 | {/* If children should be used instead of body, body will be empty, so it's safe to have both */}
19 |
20 | {/* Include children to support any normal MDX files in the project */}
21 |
22 | {children}
23 |
24 |
25 | )
26 | }
27 |
28 | const DefaultPage = ({ pageContext, ...props }) => {
29 | return (
30 |
35 | )
36 | }
37 |
38 | export default DefaultPage
39 |
--------------------------------------------------------------------------------
/src/app-layout.component.js:
--------------------------------------------------------------------------------
1 | import React from "react"
2 | import PropTypes from "prop-types"
3 | import { StaticQuery, graphql } from "gatsby"
4 |
5 | import { Header, Menu } from "./components"
6 |
7 | // Global application wrapper
8 | export const AppLayout = ({ children, pageContext }) => (
9 | {
20 | return (
21 | <>
22 |
23 |
24 |
32 | {children}
33 |
38 |
39 | >
40 | )}
41 | }
42 | />
43 | )
44 |
45 | AppLayout.propTypes = {
46 | children: PropTypes.node.isRequired,
47 | }
48 |
49 | export default AppLayout
50 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 |
8 | # Runtime data
9 | pids
10 | *.pid
11 | *.seed
12 | *.pid.lock
13 |
14 | # Directory for instrumented libs generated by jscoverage/JSCover
15 | lib-cov
16 |
17 | # Coverage directory used by tools like istanbul
18 | coverage
19 |
20 | # nyc test coverage
21 | .nyc_output
22 |
23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
24 | .grunt
25 |
26 | # Bower dependency directory (https://bower.io/)
27 | bower_components
28 |
29 | # node-waf configuration
30 | .lock-wscript
31 |
32 | # Compiled binary addons (http://nodejs.org/api/addons.html)
33 | build/Release
34 |
35 | # Dependency directories
36 | node_modules/
37 | jspm_packages/
38 |
39 | # Typescript v1 declaration files
40 | typings/
41 |
42 | # Optional npm cache directory
43 | .npm
44 |
45 | # Optional eslint cache
46 | .eslintcache
47 |
48 | # Optional REPL history
49 | .node_repl_history
50 |
51 | # Output of 'npm pack'
52 | *.tgz
53 |
54 | # dotenv environment variables file
55 | .env
56 |
57 | # gatsby files
58 | .cache/
59 | public
60 |
61 | # Mac files
62 | .DS_Store
63 |
64 | # Yarn
65 | yarn-error.log
66 | .pnp/
67 | .pnp.js
68 | # Yarn Integrity file
69 | .yarn-integrity
70 |
71 | # Webstorm
72 | .idea
73 |
--------------------------------------------------------------------------------
/src/cms/editor-components/testimonial.editor.js:
--------------------------------------------------------------------------------
1 | const testimonialEditor = props =>
2 | `
4 | ${props.quote || ""}`
5 |
6 | export const testimonialEditorConfig = {
7 | // Internal id of the component
8 | id: "testimonial",
9 | // Visible label
10 | label: "Testimonial",
11 | // Fields the user need to fill out when adding an instance of the component
12 | fields: [
13 | { label: "Image", name: "image", widget: "image", required: false },
14 | { label: "Quote", name: "quote", widget: "markdown" },
15 | { label: "Attribution", name: "attribution", widget: "markdown" },
16 | ],
17 | // Pattern to identify a block as being an instance of this component
18 | pattern: /(\S+)<\/Testimonial>/g,
19 | // Function to extract data elements from the regexp match
20 | fromBlock: function(match) {
21 | return {
22 | image: match[1],
23 | attribution: match[2],
24 | quote: match[3],
25 | }
26 | },
27 | // Function to create a text block from an instance of this component
28 | toBlock: function(props) {
29 | return testimonialEditor(props)
30 | },
31 | // Preview output for this component. Can either be a string or a React component
32 | // (component gives better render performance)
33 | toPreview: function(props) {
34 | return testimonialEditor(props)
35 | },
36 | }
37 |
--------------------------------------------------------------------------------
/src/cms/editor-components/call-to-action.editor.js:
--------------------------------------------------------------------------------
1 | const ctaEditor = props =>
2 | `${props.text || ""}`
3 |
4 | export const ctaEditorConfig = {
5 | // Internal id of the component
6 | id: "cta",
7 | // Visible label
8 | label: "Call to Action",
9 | // Fields the user need to fill out when adding an instance of the component
10 | fields: [
11 | { label: "Text", name: "text", widget: "string" },
12 | { label: "Link", name: "url", widget: "string" },
13 | {
14 | label: "Background Colour",
15 | name: "bgColor",
16 | widget: "select",
17 | options: ["crimson", "seagreen", "rebeccapurple", "midnightblue"],
18 | default: "rebeccapurple"
19 | },
20 | ],
21 | // Pattern to identify a block as being an instance of this component
22 | pattern: /(\S+)<\/CallToAction>/g,
23 | // Function to extract data elements from the regexp match
24 | fromBlock: function(match) {
25 | return {
26 | url: match[1],
27 | bgColor: match[2],
28 | text: match[3],
29 | }
30 | },
31 | // Function to create a text block from an instance of this component
32 | toBlock: function(props) {
33 | return ctaEditor(props)
34 | },
35 | // Preview output for this component. Can either be a string or a React component
36 | // (component gives better render performance)
37 | toPreview: function(props) {
38 | return ctaEditor(props)
39 | },
40 | }
41 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "gatsby-mdx-netlify-cms-starter",
3 | "private": true,
4 | "description": "Gatsby starter configured to work with MDX and Netlify CMS",
5 | "version": "0.3.0",
6 | "author": "Renee Blackburn ",
7 | "dependencies": {
8 | "@mdx-js/mdx": "^1.5.1",
9 | "@mdx-js/react": "^1.5.1",
10 | "@mdx-js/runtime": "^1.5.1",
11 | "@mdx-js/tag": "^0.18.0",
12 | "gatsby": "^2.13.14",
13 | "gatsby-image": "^2.2.5",
14 | "gatsby-plugin-manifest": "^2.0.19",
15 | "gatsby-plugin-mdx": "^1.0.56",
16 | "gatsby-plugin-netlify-cms": "^4.1.6",
17 | "gatsby-plugin-offline": "^2.2.2",
18 | "gatsby-plugin-react-helmet": "^3.1.1",
19 | "gatsby-plugin-sharp": "^2.0.35",
20 | "gatsby-source-filesystem": "^2.1.4",
21 | "gatsby-transformer-sharp": "^2.1.14",
22 | "netlify-cms-app": "^2.9.7",
23 | "prop-types": "^15.7.2",
24 | "react": "^16.8.6",
25 | "react-dom": "^16.8.6",
26 | "react-helmet": "^5.2.1"
27 | },
28 | "devDependencies": {
29 | "prettier": "^1.18.2"
30 | },
31 | "keywords": [
32 | "gatsby", "mdx"
33 | ],
34 | "license": "MIT",
35 | "scripts": {
36 | "build": "gatsby build",
37 | "develop": "gatsby develop",
38 | "format": "prettier --write src/**/*.{js,jsx}",
39 | "start": "npm run develop",
40 | "serve": "gatsby serve",
41 | "test": "echo \"Write tests! -> https://gatsby.app/unit-testing\""
42 | },
43 | "repository": {
44 | "type": "git",
45 | "url": "https://github.com/renvrant/gatsby-mdx-netlify-cms-starter"
46 | },
47 | "bugs": {
48 | "url": "https://github.com/gatsbyjs/gatsby/issues"
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/gatsby-config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | siteMetadata: {
3 | title: `Gatsby-MDX + Netlify-CMS Starter`,
4 | description: `Starter for Gatsby-MDX + Netlify CMS`,
5 | author: `@renvrant`,
6 | },
7 | plugins: [
8 | `gatsby-plugin-react-helmet`,
9 | {
10 | resolve: `gatsby-source-filesystem`,
11 | options: {
12 | name: `images`,
13 | path: `${__dirname}/src/images`,
14 | },
15 | },
16 | `gatsby-transformer-sharp`,
17 | `gatsby-plugin-sharp`,
18 | {
19 | resolve: `gatsby-plugin-mdx`,
20 | options: {
21 | extensions: ['.mdx', '.md'],
22 | defaultLayouts: {
23 | // This entry template will switch the page template based on
24 | // a frontmatter value provided in the CMS, allowing users to
25 | // choose different template layouts.
26 | default: require.resolve(`./src/page-templates/cms-entry.template.js`)
27 | },
28 | }
29 | },
30 | {
31 | resolve: `gatsby-plugin-manifest`,
32 | options: {
33 | name: `gatsby-starter-default`,
34 | short_name: `starter`,
35 | start_url: `/`,
36 | background_color: `#663399`,
37 | theme_color: `#663399`,
38 | display: `minimal-ui`,
39 | icon: `src/images/gatsby-icon.png`, // This path is relative to the root of the site.
40 | },
41 | },
42 | // this (optional) plugin enables Progressive Web App + Offline functionality
43 | // To learn more, visit: https://gatsby.app/offline
44 | // 'gatsby-plugin-offline',
45 | {
46 | resolve: `gatsby-plugin-netlify-cms`,
47 | options: {
48 | modulePath: `${__dirname}/src/cms/cms.js`, // for custom preview in the Netlify CMS
49 | },
50 | },
51 | ],
52 | }
53 |
--------------------------------------------------------------------------------
/static/admin/config.yml:
--------------------------------------------------------------------------------
1 | backend:
2 | name: github
3 | repo: renvrant/gatsby-mdx-netlify-cms-starter
4 | branch: master
5 |
6 | media_folder: uploads/img
7 | public_folder: /img
8 |
9 | collections:
10 | - name: "mainPages"
11 | label: "Main Pages and Settings"
12 | files:
13 | - file: "src/pages/index.md"
14 | label: "Home"
15 | name: "home"
16 | fields:
17 | - {
18 | label: "Template Key",
19 | name: "templateKey",
20 | widget: "hidden",
21 | default: "home-page",
22 | }
23 | - { label: Title, name: title, widget: "string" }
24 | - {
25 | label: Sections,
26 | name: sections,
27 | widget: list,
28 | fields:
29 | [
30 | { label: Title, name: title, widget: string },
31 | { label: Body, name: body, widget: markdown },
32 | ]
33 | }
34 | - file: "src/pages/config.md"
35 | label: "Global Settings"
36 | name: "config"
37 | fields:
38 | - {
39 | label: "Template Key",
40 | name: "templateKey",
41 | widget: "hidden",
42 | default: "hidden-page",
43 | }
44 | - { label: Site Title, name: title, widget: "string" }
45 | - { label: Site Description, name: desc, widget: "string" }
46 | - {
47 | label: Menu,
48 | name: menu_nav,
49 | widget: list,
50 | fields:
51 | [
52 | { label: Text, name: text, widget: string },
53 | { label: URL, name: url, widget: string },
54 | ]
55 | }
56 | - name: "content"
57 | label: "Content Pages"
58 | folder: "src/pages/content"
59 | create: true
60 | fields:
61 | - { label: "Title", name: "title", widget: "string" }
62 | - { label: "Description", name: "description", widget: "text" }
63 | - { label: "Body", name: "body", widget: "markdown" }
64 |
--------------------------------------------------------------------------------
/src/components/seo.js:
--------------------------------------------------------------------------------
1 | import React from "react"
2 | import PropTypes from "prop-types"
3 | import Helmet from "react-helmet"
4 | import { StaticQuery, graphql } from "gatsby"
5 |
6 | export function SEO({ description, lang, meta, keywords, title }) {
7 | return (
8 | {
11 | const metaDescription =
12 | description || data.site.siteMetadata.description
13 | return (
14 | 0
56 | ? {
57 | name: `keywords`,
58 | content: keywords.join(`, `),
59 | }
60 | : []
61 | )
62 | .concat(meta)}
63 | />
64 | )
65 | }}
66 | />
67 | )
68 | }
69 |
70 | SEO.defaultProps = {
71 | lang: `en`,
72 | meta: [],
73 | keywords: [],
74 | }
75 |
76 | SEO.propTypes = {
77 | description: PropTypes.string,
78 | lang: PropTypes.string,
79 | meta: PropTypes.array,
80 | keywords: PropTypes.arrayOf(PropTypes.string),
81 | title: PropTypes.string.isRequired,
82 | }
83 |
84 | const detailsQuery = graphql`
85 | query DefaultSEOQuery {
86 | site {
87 | siteMetadata {
88 | title
89 | description
90 | author
91 | }
92 | }
93 | }
94 | `
95 |
--------------------------------------------------------------------------------
/src/pages/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Home Page
3 | templateKey: "home-page"
4 | sections:
5 | - body: >-
6 | Extended from the Gatsby starter, this starter aims to provide an example for using Gatsby-MDX with Netlify.
7 |
8 | ## Features
9 |
10 | * Swap page template based on CMS key, allowing editors to choose different page templates
11 |
12 | * Support CMS configurations that save markdown in frontmatter fields with an mdx-enabled markdown renderer component (with example)
13 |
14 | * [Hide pages from being editable by the CMS](/cms-unreachable)
15 |
16 | * Extend Netlify CMS editor to support the insertion of a React component, allowing your editors to include things like buttons or testimonials
17 |
18 | * Swap default HTML elements in posts for React components, allowing for greater control
19 |
20 | * All the usual Gatsby + MDX stuff
21 |
22 | Check out the Repo
23 |
24 | title: About This Starter
25 | - body: >-
26 | Go through each of these directories to understand the project and extend from it.
27 |
28 | * *src/cms* - Utilities for working with FrontMatter which Netlify CMS depends on, example previews and example widget registration. This folder also includes a whitelist of components that will be included in the MDX render scope in **cms-components.constants.js**.
29 |
30 | * *src/components* - Components, mostly default with a few additions such as a call to action and a smart link.
31 |
32 | * *src/core* - Core components to render markdown, catch errors
33 |
34 | * *src/page-templates* - Templates for CMS pages and an entry template component that will be used to determine what template should be shown where. Look in particular at **cms-entry.template.js**
35 |
36 | * *src/pages* - Editor content. All CMS-created pages will live in the content directory. Other pages may be modified from the CMS, but cannot be created or deleted.
37 |
38 | * *static/admin* - CMS Editor configuration.
39 | title: Project Overview
40 | - body: |-
41 |
42 | The `CMSTemplate` component in conjunction with the hidden `templateKey` var controls which template will be used to render each content page. The `CMSTemplate` component will try to map the value of `templateKey` to a component, and fall back to a default if nothing is found. Please see the component for more details.
43 | title: About Template Keys
44 | - body: |-
45 | Due to the way Netlify CMS works, some CMS content is saved as Markdown `frontmatter` rather than actual markdown. Therefore, fields with a markdown editor will save a raw markdown string. It is up to our templates to correctly parse markdown. For this, we have the core component `` which will parse MDX upon receiving an MDX string and include supplied React components as appropriate. Under the hood, this uses [@mdx/runtime](https://mdxjs.com/advanced/runtime) so please look there fore configuration details.
46 | title: Frontmatter & Markdown
47 | ---
48 |
49 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Gatsby + Gastby-MDX + Netlify-CMS Starter
2 |
3 | Extended from the Gatsby starter, this starter aims to provide an example for using Gatsby-MDX with Netlify.
4 |
5 | [](https://app.netlify.com/sites/mystifying-mclean-5c7fce/deploys)
6 |
7 |
8 | [](https://app.netlify.com/start/deploy?repository=https://github.com/renvrant/gatsby-mdx-netlify-cms-starter)
9 |
10 | ## Features
11 |
12 | - Support React Components in your CMS editing workflow through MDX
13 | - Read .MD and .MDX files as pages automatically
14 | - Swap page template based on CMS key, allowing editors to choose different page templates
15 | - Support CMS configurations that save markdown in frontmatter fields with an mdx-enabled markdown renderer component (with example)
16 | - Hide pages from being editable by the CMS
17 | - Extend Netlify CMS editor to support the insertion of a React component, allowing your editors to include things like buttons or testimonials
18 | - Swap default HTML elements in posts for React components, allowing for greater control
19 | - All the other Gatsby + MDX stuff
20 |
21 | ## Developing Locally
22 |
23 | `yarn develop` or `npm run develop` @ localhost:8000
24 |
25 | Your development environment will read from your local .md files, but will *not* hot reload changes to the .md files. To make a change in the markdown and see it reflected:
26 |
27 | 1. Stop the dev server
28 | 2. Run `rm -rf .cache` to remove the gatsby cache
29 | 3. Restart the dev server
30 |
31 | ### Local Admin Panel
32 |
33 | While running the dev server:
34 |
35 | `localhost:8000/admin`
36 |
37 | Log in using your Netlify credentials.
38 |
39 | Use the local admin to verify changes to your CMS config. Please note that the state of all markdown content will reflect the state of the github master branch, NOT your local changes.
40 |
41 | ## Building
42 |
43 | `yarn build` or `npm run build`
44 |
45 | ## Project Overview
46 |
47 | Go through each of these directories to understand the project and extend from it.
48 |
49 | *src/cms* - Utilities for working with FrontMatter which Netlify CMS depends on, example previews and example widget registration. This folder also includes a whitelist of components that will be included in the MDX render scope in **cms-components.constants.js**.
50 |
51 | *src/components* - Components, mostly default with a few additions such as a call to action and a smart link.
52 |
53 | *src/core* - Core components to render markdown, catch errors
54 |
55 | *src/page-templates* - Templates for CMS pages and an entry template component that will be used to determine what template should be shown where. Look in particular at **cms-entry.template.js**
56 |
57 | *src/pages* - Editor content. All CMS-created pages will live in the content directory. Other pages may be modified from the CMS, but cannot be created or deleted.
58 |
59 | *static/admin* - CMS Editor configuration.
60 |
61 | ## Templates and Template Keys
62 |
63 | The `CMSTemplate` component in conjunction with the hidden `templateKey` var controls which template will be used to render each content page. The `CMSTemplate` component will try to map the value of `templateKey` to a component, and fall back to a default if nothing is found. Please see the component for more details.
64 |
65 | ## Markdown and Frontmatter
66 |
67 | Due to the way Netlify works, some CMS content is saved as Markdown `frontmatter` rather than actual markdown. Therefore, fields with a markdown editor will save a raw markdown string. It is up to our templates to correctly parse markdown. For this, we have the core component `` which will parse MDX upon receiving an MDX string and include supplied React components as appropriate. Under the hood, this uses [@mdx/runtime](https://mdxjs.com/advanced/runtime) so please look there fore configuration details.
68 |
69 | ---
70 |
71 | From Gatsby's Starter Docs:
72 |
73 | ## 🚀 Quick start
74 |
75 |
76 | 1. **Start developing.**
77 |
78 | Navigate into your new site’s directory and start it up.
79 |
80 | ```sh
81 | cd my-default-starter/
82 | gatsby develop
83 | ```
84 |
85 | 1. **Open the source code and start editing!**
86 |
87 | Your site is now running at `http://localhost:8000`!
88 |
89 | _Note: You'll also see a second link: _`http://localhost:8000/___graphql`_. This is a tool you can use to experiment with querying your data. Learn more about using this tool in the [Gatsby tutorial](https://www.gatsbyjs.org/tutorial/part-five/#introducing-graphiql)._
90 |
91 | Open the `my-default-starter` directory in your code editor of choice and edit `src/pages/index.js`. Save your changes and the browser will update in real time!
92 |
93 | ## 🧐 What's inside?
94 |
95 | A quick look at the top-level files and directories you'll see in a Gatsby project.
96 |
97 | .
98 | ├── node_modules
99 | ├── src
100 | ├── .gitignore
101 | ├── .prettierrc
102 | ├── gatsby-browser.js
103 | ├── gatsby-config.js
104 | ├── gatsby-node.js
105 | ├── gatsby-ssr.js
106 | ├── LICENSE
107 | ├── package-lock.json
108 | ├── package.json
109 | └── README.md
110 |
111 | 1. **`/node_modules`**: This directory contains all of the modules of code that your project depends on (npm packages) are automatically installed.
112 |
113 | 2. **`/src`**: This directory will contain all of the code related to what you will see on the front-end of your site (what you see in the browser) such as your site header or a page template. `src` is a convention for “source code”.
114 |
115 | 3. **`.gitignore`**: This file tells git which files it should not track / not maintain a version history for.
116 |
117 | 4. **`.prettierrc`**: This is a configuration file for [Prettier](https://prettier.io/). Prettier is a tool to help keep the formatting of your code consistent.
118 |
119 | 5. **`gatsby-browser.js`**: This file is where Gatsby expects to find any usage of the [Gatsby browser APIs](https://www.gatsbyjs.org/docs/browser-apis/) (if any). These allow customization/extension of default Gatsby settings affecting the browser.
120 |
121 | 6. **`gatsby-config.js`**: This is the main configuration file for a Gatsby site. This is where you can specify information about your site (metadata) like the site title and description, which Gatsby plugins you’d like to include, etc. (Check out the [config docs](https://www.gatsbyjs.org/docs/gatsby-config/) for more detail).
122 |
123 | 7. **`gatsby-node.js`**: This file is where Gatsby expects to find any usage of the [Gatsby Node APIs](https://www.gatsbyjs.org/docs/node-apis/) (if any). These allow customization/extension of default Gatsby settings affecting pieces of the site build process.
124 |
125 | 8. **`gatsby-ssr.js`**: This file is where Gatsby expects to find any usage of the [Gatsby server-side rendering APIs](https://www.gatsbyjs.org/docs/ssr-apis/) (if any). These allow customization of default Gatsby settings affecting server-side rendering.
126 |
127 | 9. **`LICENSE`**: Gatsby is licensed under the MIT license.
128 |
129 | 10. **`package-lock.json`** (See `package.json` below, first). This is an automatically generated file based on the exact versions of your npm dependencies that were installed for your project. **(You won’t change this file directly).**
130 |
131 | 11. **`package.json`**: A manifest file for Node.js projects, which includes things like metadata (the project’s name, author, etc). This manifest is how npm knows which packages to install for your project.
132 |
133 | 12. **`README.md`**: A text file containing useful reference information about your project.
134 |
135 | ## 🎓 Learning Gatsby
136 |
137 | Looking for more guidance? Full documentation for Gatsby lives [on the website](https://www.gatsbyjs.org/). Here are some places to start:
138 |
139 | - **For most developers, we recommend starting with our [in-depth tutorial for creating a site with Gatsby](https://www.gatsbyjs.org/tutorial/).** It starts with zero assumptions about your level of ability and walks through every step of the process.
140 |
141 | - **To dive straight into code samples, head [to our documentation](https://www.gatsbyjs.org/docs/).** In particular, check out the _Guides_, _API Reference_, and _Advanced Tutorials_ sections in the sidebar.
142 |
--------------------------------------------------------------------------------
/src/app.css:
--------------------------------------------------------------------------------
1 | html {
2 | font-family: sans-serif;
3 | -ms-text-size-adjust: 100%;
4 | -webkit-text-size-adjust: 100%;
5 | }
6 | body {
7 | margin: 0;
8 | -webkit-font-smoothing: antialiased;
9 | -moz-osx-font-smoothing: grayscale;
10 | }
11 | article,
12 | aside,
13 | details,
14 | figcaption,
15 | figure,
16 | footer,
17 | header,
18 | main,
19 | menu,
20 | nav,
21 | section,
22 | summary {
23 | display: block;
24 | }
25 | audio,
26 | canvas,
27 | progress,
28 | video {
29 | display: inline-block;
30 | }
31 | audio:not([controls]) {
32 | display: none;
33 | height: 0;
34 | }
35 | progress {
36 | vertical-align: baseline;
37 | }
38 | [hidden],
39 | template {
40 | display: none;
41 | }
42 | a {
43 | background-color: transparent;
44 | -webkit-text-decoration-skip: objects;
45 | }
46 | a:active,
47 | a:hover {
48 | outline-width: 0;
49 | }
50 | abbr[title] {
51 | border-bottom: none;
52 | text-decoration: underline;
53 | text-decoration: underline dotted;
54 | }
55 | b,
56 | strong {
57 | font-weight: inherit;
58 | font-weight: bolder;
59 | }
60 | dfn {
61 | font-style: italic;
62 | }
63 | h1 {
64 | font-size: 2em;
65 | margin: 0.67em 0;
66 | }
67 | mark {
68 | background-color: #ff0;
69 | color: #000;
70 | }
71 | small {
72 | font-size: 80%;
73 | }
74 | sub,
75 | sup {
76 | font-size: 75%;
77 | line-height: 0;
78 | position: relative;
79 | vertical-align: baseline;
80 | }
81 | sub {
82 | bottom: -0.25em;
83 | }
84 | sup {
85 | top: -0.5em;
86 | }
87 | img {
88 | border-style: none;
89 | }
90 | svg:not(:root) {
91 | overflow: hidden;
92 | }
93 | code,
94 | kbd,
95 | pre,
96 | samp {
97 | font-family: monospace, monospace;
98 | font-size: 1em;
99 | }
100 | figure {
101 | margin: 1em 40px;
102 | }
103 | hr {
104 | box-sizing: content-box;
105 | height: 0;
106 | overflow: visible;
107 | }
108 | button,
109 | input,
110 | optgroup,
111 | select,
112 | textarea {
113 | font: inherit;
114 | margin: 0;
115 | }
116 | optgroup {
117 | font-weight: 700;
118 | }
119 | button,
120 | input {
121 | overflow: visible;
122 | }
123 | button,
124 | select {
125 | text-transform: none;
126 | }
127 | [type="reset"],
128 | [type="submit"],
129 | button,
130 | html [type="button"] {
131 | -webkit-appearance: button;
132 | }
133 | [type="button"]::-moz-focus-inner,
134 | [type="reset"]::-moz-focus-inner,
135 | [type="submit"]::-moz-focus-inner,
136 | button::-moz-focus-inner {
137 | border-style: none;
138 | padding: 0;
139 | }
140 | [type="button"]:-moz-focusring,
141 | [type="reset"]:-moz-focusring,
142 | [type="submit"]:-moz-focusring,
143 | button:-moz-focusring {
144 | outline: 1px dotted ButtonText;
145 | }
146 | fieldset {
147 | border: 1px solid silver;
148 | margin: 0 2px;
149 | padding: 0.35em 0.625em 0.75em;
150 | }
151 | legend {
152 | box-sizing: border-box;
153 | color: inherit;
154 | display: table;
155 | max-width: 100%;
156 | padding: 0;
157 | white-space: normal;
158 | }
159 | textarea {
160 | overflow: auto;
161 | }
162 | [type="checkbox"],
163 | [type="radio"] {
164 | box-sizing: border-box;
165 | padding: 0;
166 | }
167 | [type="number"]::-webkit-inner-spin-button,
168 | [type="number"]::-webkit-outer-spin-button {
169 | height: auto;
170 | }
171 | [type="search"] {
172 | -webkit-appearance: textfield;
173 | outline-offset: -2px;
174 | }
175 | [type="search"]::-webkit-search-cancel-button,
176 | [type="search"]::-webkit-search-decoration {
177 | -webkit-appearance: none;
178 | }
179 | ::-webkit-input-placeholder {
180 | color: inherit;
181 | opacity: 0.54;
182 | }
183 | ::-webkit-file-upload-button {
184 | -webkit-appearance: button;
185 | font: inherit;
186 | }
187 | html {
188 | font: 112.5%/1.45em georgia, serif;
189 | box-sizing: border-box;
190 | overflow-y: scroll;
191 | }
192 | * {
193 | box-sizing: inherit;
194 | }
195 | *:before {
196 | box-sizing: inherit;
197 | }
198 | *:after {
199 | box-sizing: inherit;
200 | }
201 | body {
202 | color: hsla(0, 0%, 0%, 0.8);
203 | font-family: georgia, serif;
204 | font-weight: normal;
205 | word-wrap: break-word;
206 | font-kerning: normal;
207 | -moz-font-feature-settings: "kern", "liga", "clig", "calt";
208 | -ms-font-feature-settings: "kern", "liga", "clig", "calt";
209 | -webkit-font-feature-settings: "kern", "liga", "clig", "calt";
210 | font-feature-settings: "kern", "liga", "clig", "calt";
211 | }
212 | img {
213 | max-width: 100%;
214 | margin-left: 0;
215 | margin-right: 0;
216 | margin-top: 0;
217 | padding-bottom: 0;
218 | padding-left: 0;
219 | padding-right: 0;
220 | padding-top: 0;
221 | margin-bottom: 1.45rem;
222 | }
223 | h1 {
224 | margin-left: 0;
225 | margin-right: 0;
226 | margin-top: 0;
227 | padding-bottom: 0;
228 | padding-left: 0;
229 | padding-right: 0;
230 | padding-top: 0;
231 | margin-bottom: 1.45rem;
232 | color: inherit;
233 | font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
234 | Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
235 | font-weight: bold;
236 | text-rendering: optimizeLegibility;
237 | font-size: 2.25rem;
238 | line-height: 1.1;
239 | }
240 | h2 {
241 | margin-left: 0;
242 | margin-right: 0;
243 | margin-top: 0;
244 | padding-bottom: 0;
245 | padding-left: 0;
246 | padding-right: 0;
247 | padding-top: 0;
248 | margin-bottom: 1.45rem;
249 | color: inherit;
250 | font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
251 | Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
252 | font-weight: bold;
253 | text-rendering: optimizeLegibility;
254 | font-size: 1.62671rem;
255 | line-height: 1.1;
256 | }
257 | h3 {
258 | margin-left: 0;
259 | margin-right: 0;
260 | margin-top: 0;
261 | padding-bottom: 0;
262 | padding-left: 0;
263 | padding-right: 0;
264 | padding-top: 0;
265 | margin-bottom: 1.45rem;
266 | color: inherit;
267 | font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
268 | Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
269 | font-weight: bold;
270 | text-rendering: optimizeLegibility;
271 | font-size: 1.38316rem;
272 | line-height: 1.1;
273 | }
274 | h4 {
275 | margin-left: 0;
276 | margin-right: 0;
277 | margin-top: 0;
278 | padding-bottom: 0;
279 | padding-left: 0;
280 | padding-right: 0;
281 | padding-top: 0;
282 | margin-bottom: 1.45rem;
283 | color: inherit;
284 | font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
285 | Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
286 | font-weight: bold;
287 | text-rendering: optimizeLegibility;
288 | font-size: 1rem;
289 | line-height: 1.1;
290 | }
291 | h5 {
292 | margin-left: 0;
293 | margin-right: 0;
294 | margin-top: 0;
295 | padding-bottom: 0;
296 | padding-left: 0;
297 | padding-right: 0;
298 | padding-top: 0;
299 | margin-bottom: 1.45rem;
300 | color: inherit;
301 | font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
302 | Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
303 | font-weight: bold;
304 | text-rendering: optimizeLegibility;
305 | font-size: 0.85028rem;
306 | line-height: 1.1;
307 | }
308 | h6 {
309 | margin-left: 0;
310 | margin-right: 0;
311 | margin-top: 0;
312 | padding-bottom: 0;
313 | padding-left: 0;
314 | padding-right: 0;
315 | padding-top: 0;
316 | margin-bottom: 1.45rem;
317 | color: inherit;
318 | font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
319 | Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
320 | font-weight: bold;
321 | text-rendering: optimizeLegibility;
322 | font-size: 0.78405rem;
323 | line-height: 1.1;
324 | }
325 | hgroup {
326 | margin-left: 0;
327 | margin-right: 0;
328 | margin-top: 0;
329 | padding-bottom: 0;
330 | padding-left: 0;
331 | padding-right: 0;
332 | padding-top: 0;
333 | margin-bottom: 1.45rem;
334 | }
335 | ul {
336 | margin-left: 1.45rem;
337 | margin-right: 0;
338 | margin-top: 0;
339 | padding-bottom: 0;
340 | padding-left: 0;
341 | padding-right: 0;
342 | padding-top: 0;
343 | margin-bottom: 1.45rem;
344 | list-style-position: outside;
345 | list-style-image: none;
346 | }
347 | ol {
348 | margin-left: 1.45rem;
349 | margin-right: 0;
350 | margin-top: 0;
351 | padding-bottom: 0;
352 | padding-left: 0;
353 | padding-right: 0;
354 | padding-top: 0;
355 | margin-bottom: 1.45rem;
356 | list-style-position: outside;
357 | list-style-image: none;
358 | }
359 | dl {
360 | margin-left: 0;
361 | margin-right: 0;
362 | margin-top: 0;
363 | padding-bottom: 0;
364 | padding-left: 0;
365 | padding-right: 0;
366 | padding-top: 0;
367 | margin-bottom: 1.45rem;
368 | }
369 | dd {
370 | margin-left: 0;
371 | margin-right: 0;
372 | margin-top: 0;
373 | padding-bottom: 0;
374 | padding-left: 0;
375 | padding-right: 0;
376 | padding-top: 0;
377 | margin-bottom: 1.45rem;
378 | }
379 | p {
380 | margin-left: 0;
381 | margin-right: 0;
382 | margin-top: 0;
383 | padding-bottom: 0;
384 | padding-left: 0;
385 | padding-right: 0;
386 | padding-top: 0;
387 | margin-bottom: 1.45rem;
388 | }
389 | figure {
390 | margin-left: 0;
391 | margin-right: 0;
392 | margin-top: 0;
393 | padding-bottom: 0;
394 | padding-left: 0;
395 | padding-right: 0;
396 | padding-top: 0;
397 | margin-bottom: 1.45rem;
398 | }
399 | pre {
400 | margin-left: 0;
401 | margin-right: 0;
402 | margin-top: 0;
403 | margin-bottom: 1.45rem;
404 | font-size: 0.85rem;
405 | line-height: 1.42;
406 | background: hsla(0, 0%, 0%, 0.04);
407 | border-radius: 3px;
408 | overflow: auto;
409 | word-wrap: normal;
410 | padding: 1.45rem;
411 | }
412 | table {
413 | margin-left: 0;
414 | margin-right: 0;
415 | margin-top: 0;
416 | padding-bottom: 0;
417 | padding-left: 0;
418 | padding-right: 0;
419 | padding-top: 0;
420 | margin-bottom: 1.45rem;
421 | font-size: 1rem;
422 | line-height: 1.45rem;
423 | border-collapse: collapse;
424 | width: 100%;
425 | }
426 | fieldset {
427 | margin-left: 0;
428 | margin-right: 0;
429 | margin-top: 0;
430 | padding-bottom: 0;
431 | padding-left: 0;
432 | padding-right: 0;
433 | padding-top: 0;
434 | margin-bottom: 1.45rem;
435 | }
436 | blockquote {
437 | margin-left: 1.45rem;
438 | margin-right: 1.45rem;
439 | margin-top: 0;
440 | padding-bottom: 0;
441 | padding-left: 0;
442 | padding-right: 0;
443 | padding-top: 0;
444 | margin-bottom: 1.45rem;
445 | }
446 | form {
447 | margin-left: 0;
448 | margin-right: 0;
449 | margin-top: 0;
450 | padding-bottom: 0;
451 | padding-left: 0;
452 | padding-right: 0;
453 | padding-top: 0;
454 | margin-bottom: 1.45rem;
455 | }
456 | noscript {
457 | margin-left: 0;
458 | margin-right: 0;
459 | margin-top: 0;
460 | padding-bottom: 0;
461 | padding-left: 0;
462 | padding-right: 0;
463 | padding-top: 0;
464 | margin-bottom: 1.45rem;
465 | }
466 | iframe {
467 | margin-left: 0;
468 | margin-right: 0;
469 | margin-top: 0;
470 | padding-bottom: 0;
471 | padding-left: 0;
472 | padding-right: 0;
473 | padding-top: 0;
474 | margin-bottom: 1.45rem;
475 | }
476 | hr {
477 | margin-left: 0;
478 | margin-right: 0;
479 | margin-top: 0;
480 | padding-bottom: 0;
481 | padding-left: 0;
482 | padding-right: 0;
483 | padding-top: 0;
484 | margin-bottom: calc(1.45rem - 1px);
485 | background: hsla(0, 0%, 0%, 0.2);
486 | border: none;
487 | height: 1px;
488 | }
489 | address {
490 | margin-left: 0;
491 | margin-right: 0;
492 | margin-top: 0;
493 | padding-bottom: 0;
494 | padding-left: 0;
495 | padding-right: 0;
496 | padding-top: 0;
497 | margin-bottom: 1.45rem;
498 | }
499 | b {
500 | font-weight: bold;
501 | }
502 | strong {
503 | font-weight: bold;
504 | }
505 | dt {
506 | font-weight: bold;
507 | }
508 | th {
509 | font-weight: bold;
510 | }
511 | li {
512 | margin-bottom: calc(1.45rem / 2);
513 | }
514 | ol li {
515 | padding-left: 0;
516 | }
517 | ul li {
518 | padding-left: 0;
519 | }
520 | li > ol {
521 | margin-left: 1.45rem;
522 | margin-bottom: calc(1.45rem / 2);
523 | margin-top: calc(1.45rem / 2);
524 | }
525 | li > ul {
526 | margin-left: 1.45rem;
527 | margin-bottom: calc(1.45rem / 2);
528 | margin-top: calc(1.45rem / 2);
529 | }
530 | blockquote *:last-child {
531 | margin-bottom: 0;
532 | }
533 | li *:last-child {
534 | margin-bottom: 0;
535 | }
536 | p *:last-child {
537 | margin-bottom: 0;
538 | }
539 | li > p {
540 | margin-bottom: calc(1.45rem / 2);
541 | }
542 | code {
543 | font-size: 0.85rem;
544 | line-height: 1.45rem;
545 | }
546 | kbd {
547 | font-size: 0.85rem;
548 | line-height: 1.45rem;
549 | }
550 | samp {
551 | font-size: 0.85rem;
552 | line-height: 1.45rem;
553 | }
554 | abbr {
555 | border-bottom: 1px dotted hsla(0, 0%, 0%, 0.5);
556 | cursor: help;
557 | }
558 | acronym {
559 | border-bottom: 1px dotted hsla(0, 0%, 0%, 0.5);
560 | cursor: help;
561 | }
562 | abbr[title] {
563 | border-bottom: 1px dotted hsla(0, 0%, 0%, 0.5);
564 | cursor: help;
565 | text-decoration: none;
566 | }
567 | thead {
568 | text-align: left;
569 | }
570 | td,
571 | th {
572 | text-align: left;
573 | border-bottom: 1px solid hsla(0, 0%, 0%, 0.12);
574 | font-feature-settings: "tnum";
575 | -moz-font-feature-settings: "tnum";
576 | -ms-font-feature-settings: "tnum";
577 | -webkit-font-feature-settings: "tnum";
578 | padding-left: 0.96667rem;
579 | padding-right: 0.96667rem;
580 | padding-top: 0.725rem;
581 | padding-bottom: calc(0.725rem - 1px);
582 | }
583 | th:first-child,
584 | td:first-child {
585 | padding-left: 0;
586 | }
587 | th:last-child,
588 | td:last-child {
589 | padding-right: 0;
590 | }
591 | tt,
592 | code {
593 | background-color: hsla(0, 0%, 0%, 0.04);
594 | border-radius: 3px;
595 | font-family: "SFMono-Regular", Consolas, "Roboto Mono", "Droid Sans Mono",
596 | "Liberation Mono", Menlo, Courier, monospace;
597 | padding: 0;
598 | padding-top: 0.2em;
599 | padding-bottom: 0.2em;
600 | }
601 | pre code {
602 | background: none;
603 | line-height: 1.42;
604 | }
605 | code:before,
606 | code:after,
607 | tt:before,
608 | tt:after {
609 | letter-spacing: -0.2em;
610 | content: " ";
611 | }
612 | pre code:before,
613 | pre code:after,
614 | pre tt:before,
615 | pre tt:after {
616 | content: "";
617 | }
618 | @media only screen and (max-width: 480px) {
619 | html {
620 | font-size: 100%;
621 | }
622 | }
623 |
--------------------------------------------------------------------------------