├── static └── _redirects ├── netlify.toml ├── src ├── api │ ├── hello.js │ └── schedule │ │ └── [search].js ├── images │ └── icon.png └── pages │ ├── 404.js │ └── index.js ├── netlify └── functions │ └── boop.js ├── .gitignore ├── gatsby-config.js ├── package.json └── README.md /static/_redirects: -------------------------------------------------------------------------------- 1 | /api/v1/* /.netlify/functions/:splat 200 2 | -------------------------------------------------------------------------------- /netlify.toml: -------------------------------------------------------------------------------- 1 | [[plugins]] 2 | package = "@netlify/plugin-gatsby" 3 | -------------------------------------------------------------------------------- /src/api/hello.js: -------------------------------------------------------------------------------- 1 | export default function handler(req, res) { 2 | res.status(200).json({ waddup: 'chat' }); 3 | } 4 | -------------------------------------------------------------------------------- /src/images/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/learnwithjason/gatsby-functions-on-netlify/main/src/images/icon.png -------------------------------------------------------------------------------- /netlify/functions/boop.js: -------------------------------------------------------------------------------- 1 | exports.handler = async () => { 2 | return { 3 | statusCode: 200, 4 | body: 'BOOP', 5 | }; 6 | }; 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | .cache/ 3 | public 4 | .netlify 5 | # @netlify/plugin-gatsby ignores start 6 | netlify/functions/gatsby 7 | # @netlify/plugin-gatsby ignores end 8 | -------------------------------------------------------------------------------- /gatsby-config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | siteMetadata: { 3 | title: 'Gatsby Functions on Netlify', 4 | }, 5 | flags: { 6 | FUNCTIONS: true, 7 | }, 8 | plugins: [ 9 | 'gatsby-plugin-react-helmet', 10 | 'gatsby-plugin-mdx', 11 | { 12 | resolve: 'gatsby-source-filesystem', 13 | options: { 14 | name: 'pages', 15 | path: './src/pages/', 16 | }, 17 | __key: 'pages', 18 | }, 19 | ], 20 | }; 21 | -------------------------------------------------------------------------------- /src/api/schedule/[search].js: -------------------------------------------------------------------------------- 1 | import fetch from 'node-fetch'; 2 | 3 | export default async function handler(req, res) { 4 | const schedule = await fetch( 5 | 'https://www.learnwithjason.dev/api/schedule', 6 | ).then((res) => res.json()); 7 | const { search = '' } = req.params; 8 | 9 | const filtered = schedule.filter((episode) => { 10 | const regex = new RegExp(search, 'i'); 11 | return episode.title.match(regex); 12 | }); 13 | 14 | res.status(200).json(filtered); 15 | } 16 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gatsby-functions-on-netlify", 3 | "version": "1.0.0", 4 | "private": true, 5 | "description": "Gatsby Functions on Netlify", 6 | "author": "Jason Lengstorf", 7 | "keywords": [ 8 | "gatsby" 9 | ], 10 | "scripts": { 11 | "develop": "gatsby develop", 12 | "start": "gatsby develop", 13 | "build": "gatsby build", 14 | "serve": "gatsby serve", 15 | "clean": "gatsby clean" 16 | }, 17 | "dependencies": { 18 | "@mdx-js/mdx": "^1.6.22", 19 | "@mdx-js/react": "^1.6.22", 20 | "gatsby": "^3.6.2", 21 | "gatsby-plugin-mdx": "^2.6.0", 22 | "gatsby-plugin-react-helmet": "^4.6.0", 23 | "gatsby-source-filesystem": "^3.6.0", 24 | "node-fetch": "^2.6.1", 25 | "react": "^17.0.1", 26 | "react-dom": "^17.0.1", 27 | "react-helmet": "^6.1.0" 28 | }, 29 | "devDependencies": { 30 | "@netlify/plugin-gatsby": "0.0.2" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/pages/404.js: -------------------------------------------------------------------------------- 1 | import * as React from "react" 2 | import { Link } from "gatsby" 3 | 4 | // styles 5 | const pageStyles = { 6 | color: "#232129", 7 | padding: "96px", 8 | fontFamily: "-apple-system, Roboto, sans-serif, serif", 9 | } 10 | const headingStyles = { 11 | marginTop: 0, 12 | marginBottom: 64, 13 | maxWidth: 320, 14 | } 15 | 16 | const paragraphStyles = { 17 | marginBottom: 48, 18 | } 19 | const codeStyles = { 20 | color: "#8A6534", 21 | padding: 4, 22 | backgroundColor: "#FFF4DB", 23 | fontSize: "1.25rem", 24 | borderRadius: 4, 25 | } 26 | 27 | // markup 28 | const NotFoundPage = () => { 29 | return ( 30 |
31 | Not found 32 |

Page not found

33 |

34 | Sorry{" "} 35 | 36 | 😔 37 | {" "} 38 | we couldn’t find what you were looking for. 39 |
40 | {process.env.NODE_ENV === "development" ? ( 41 | <> 42 |
43 | Try creating a page in src/pages/. 44 |
45 | 46 | ) : null} 47 |
48 | Go home. 49 |

50 |
51 | ) 52 | } 53 | 54 | export default NotFoundPage 55 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | Gatsby 4 | 5 |

6 |

7 | Gatsby minimal starter 8 |

9 | 10 | ## 🚀 Quick start 11 | 12 | 1. **Create a Gatsby site.** 13 | 14 | Use the Gatsby CLI to create a new site, specifying the minimal starter. 15 | 16 | ```shell 17 | # create a new Gatsby site using the minimal starter 18 | npm init gatsby 19 | ``` 20 | 21 | 2. **Start developing.** 22 | 23 | Navigate into your new site’s directory and start it up. 24 | 25 | ```shell 26 | cd my-gatsby-site/ 27 | npm run develop 28 | ``` 29 | 30 | 3. **Open the code and start customizing!** 31 | 32 | Your site is now running at http://localhost:8000! 33 | 34 | Edit `src/pages/index.js` to see your site update in real-time! 35 | 36 | 4. **Learn more** 37 | 38 | - [Documentation](https://www.gatsbyjs.com/docs/?utm_source=starter&utm_medium=readme&utm_campaign=minimal-starter) 39 | 40 | - [Tutorials](https://www.gatsbyjs.com/tutorial/?utm_source=starter&utm_medium=readme&utm_campaign=minimal-starter) 41 | 42 | - [Guides](https://www.gatsbyjs.com/tutorial/?utm_source=starter&utm_medium=readme&utm_campaign=minimal-starter) 43 | 44 | - [API Reference](https://www.gatsbyjs.com/docs/api-reference/?utm_source=starter&utm_medium=readme&utm_campaign=minimal-starter) 45 | 46 | - [Plugin Library](https://www.gatsbyjs.com/plugins?utm_source=starter&utm_medium=readme&utm_campaign=minimal-starter) 47 | 48 | - [Cheat Sheet](https://www.gatsbyjs.com/docs/cheat-sheet/?utm_source=starter&utm_medium=readme&utm_campaign=minimal-starter) 49 | 50 | ## 🚀 Quick start (Gatsby Cloud) 51 | 52 | Deploy this starter with one click on [Gatsby Cloud](https://www.gatsbyjs.com/cloud/): 53 | 54 | [Deploy to Gatsby Cloud](https://www.gatsbyjs.com/dashboard/deploynow?url=https://github.com/gatsbyjs/gatsby-starter-minimal) 55 | -------------------------------------------------------------------------------- /src/pages/index.js: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | 3 | // styles 4 | const pageStyles = { 5 | color: '#232129', 6 | padding: 96, 7 | fontFamily: '-apple-system, Roboto, sans-serif, serif', 8 | }; 9 | const headingStyles = { 10 | marginTop: 0, 11 | marginBottom: 64, 12 | maxWidth: 320, 13 | }; 14 | const headingAccentStyles = { 15 | color: '#663399', 16 | }; 17 | const paragraphStyles = { 18 | marginBottom: 48, 19 | }; 20 | const codeStyles = { 21 | color: '#8A6534', 22 | padding: 4, 23 | backgroundColor: '#FFF4DB', 24 | fontSize: '1.25rem', 25 | borderRadius: 4, 26 | }; 27 | const listStyles = { 28 | marginBottom: 96, 29 | paddingLeft: 0, 30 | }; 31 | const listItemStyles = { 32 | fontWeight: 300, 33 | fontSize: 24, 34 | maxWidth: 560, 35 | marginBottom: 30, 36 | }; 37 | 38 | const linkStyle = { 39 | color: '#8954A8', 40 | fontWeight: 'bold', 41 | fontSize: 16, 42 | verticalAlign: '5%', 43 | }; 44 | 45 | const docLinkStyle = { 46 | ...linkStyle, 47 | listStyleType: 'none', 48 | marginBottom: 24, 49 | }; 50 | 51 | const descriptionStyle = { 52 | color: '#232129', 53 | fontSize: 14, 54 | marginTop: 10, 55 | marginBottom: 0, 56 | lineHeight: 1.25, 57 | }; 58 | 59 | const docLink = { 60 | text: 'Documentation', 61 | url: 'https://www.gatsbyjs.com/docs/', 62 | color: '#8954A8', 63 | }; 64 | 65 | const badgeStyle = { 66 | color: '#fff', 67 | backgroundColor: '#088413', 68 | border: '1px solid #088413', 69 | fontSize: 11, 70 | fontWeight: 'bold', 71 | letterSpacing: 1, 72 | borderRadius: 4, 73 | padding: '4px 6px', 74 | display: 'inline-block', 75 | position: 'relative', 76 | top: -2, 77 | marginLeft: 10, 78 | lineHeight: 1, 79 | }; 80 | 81 | // data 82 | const links = [ 83 | { 84 | text: 'Tutorial', 85 | url: 'https://www.gatsbyjs.com/docs/tutorial/', 86 | description: 87 | "A great place to get started if you're new to web development. Designed to guide you through setting up your first Gatsby site.", 88 | color: '#E95800', 89 | }, 90 | { 91 | text: 'How to Guides', 92 | url: 'https://www.gatsbyjs.com/docs/how-to/', 93 | description: 94 | "Practical step-by-step guides to help you achieve a specific goal. Most useful when you're trying to get something done.", 95 | color: '#1099A8', 96 | }, 97 | { 98 | text: 'Reference Guides', 99 | url: 'https://www.gatsbyjs.com/docs/reference/', 100 | description: 101 | "Nitty-gritty technical descriptions of how Gatsby works. Most useful when you need detailed information about Gatsby's APIs.", 102 | color: '#BC027F', 103 | }, 104 | { 105 | text: 'Conceptual Guides', 106 | url: 'https://www.gatsbyjs.com/docs/conceptual/', 107 | description: 108 | 'Big-picture explanations of higher-level Gatsby concepts. Most useful for building understanding of a particular topic.', 109 | color: '#0D96F2', 110 | }, 111 | { 112 | text: 'Plugin Library', 113 | url: 'https://www.gatsbyjs.com/plugins', 114 | description: 115 | 'Add functionality and customize your Gatsby site or app with thousands of plugins built by our amazing developer community.', 116 | color: '#8EB814', 117 | }, 118 | { 119 | text: 'Build and Host', 120 | url: 'https://www.gatsbyjs.com/cloud', 121 | badge: true, 122 | description: 123 | 'Now you’re ready to show the world! Give your Gatsby site superpowers: Build and host on Gatsby Cloud. Get started for free!', 124 | color: '#663399', 125 | }, 126 | ]; 127 | 128 | // markup 129 | const IndexPage = () => { 130 | return ( 131 |
132 | Home Page 133 |

Waddup Chat?!

134 |

135 | Let's play with Gatsby Functions on Netlify! 136 |

137 |
138 | ); 139 | }; 140 | 141 | export default IndexPage; 142 | --------------------------------------------------------------------------------