Skip to content

Commit f356a5f

Browse files
committed
Setup starter project
1 parent 551a754 commit f356a5f

21 files changed

+657
-252
lines changed

Diff for: .env.example

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
GITHUB_API_TOKEN=

Diff for: README.md

+35-65
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,67 @@
1-
<!-- AUTO-GENERATED-CONTENT:START (STARTER) -->
21
<p align="center">
3-
<a href="https://www.gatsbyjs.org">
4-
<img alt="Gatsby" src="https://www.gatsbyjs.org/monogram.svg" width="60" />
2+
<a href="https://gatsby-starter-github-api.netlify.com">
3+
<img alt="Gatsby" src="https://raw.githubusercontent.com/lundgren2/gatsby-starter-github-api/master/src/images/github-gatsby.png" width="400" />
54
</a>
65
</p>
76
<h1 align="center">
8-
Gatsby's default starter
7+
Gatsby Starter Github API
98
</h1>
109

11-
Kick off your project with this default boilerplate. This starter ships with the main Gatsby configuration files you might need to get up and running blazing fast with the blazing fast app generator for React.
10+
This is an example sourcing data from [GitHub GraphQL API v4](https://developer.github.com/v4/) using [gatsby-source-github-api](https://www.gatsbyjs.org/packages/gatsby-source-github-api)
1211

13-
_Have another more specific idea? You may want to check out our vibrant collection of [official and community-created starters](https://www.gatsbyjs.org/docs/gatsby-starters/)._
14-
15-
## 🚀 Quick start
12+
## How to use
1613

1714
1. **Create a Gatsby site.**
1815

1916
Use the Gatsby CLI to create a new site, specifying the default starter.
2017

2118
```sh
2219
# create a new Gatsby site using the default starter
23-
gatsby new my-default-starter https://github.com/gatsbyjs/gatsby-starter-default
24-
```
25-
26-
1. **Start developing.**
27-
28-
Navigate into your new site’s directory and start it up.
29-
30-
```sh
31-
cd my-default-starter/
32-
gatsby develop
20+
gatsby new my-portfolio https://github.com/gatsbyjs/gatsby-starter-default
21+
cd my-portfolio/
3322
```
3423

35-
1. **Open the source code and start editing!**
36-
37-
Your site is now running at `http://localhost:8000`!
38-
39-
_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)._
40-
41-
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!
42-
43-
## 🧐 What's inside?
44-
45-
A quick look at the top-level files and directories you'll see in a Gatsby project.
46-
47-
.
48-
├── node_modules
49-
├── src
50-
├── .gitignore
51-
├── .prettierrc
52-
├── gatsby-browser.js
53-
├── gatsby-config.js
54-
├── gatsby-node.js
55-
├── gatsby-ssr.js
56-
├── LICENSE
57-
├── package-lock.json
58-
├── package.json
59-
└── README.md
60-
61-
1. **`/node_modules`**: This directory contains all of the modules of code that your project depends on (npm packages) are automatically installed.
62-
63-
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”.
64-
65-
3. **`.gitignore`**: This file tells git which files it should not track / not maintain a version history for.
24+
2. **Generate GitHub API Token**
25+
Follow these instructions: https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/
6626

67-
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.
27+
3. **Add your generated token to the `env` file**
6828

69-
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.
29+
```sh
30+
mv .env.example .env
31+
```
32+
```sh
33+
# .env
34+
GITHUB_API_TOKEN=your-token-here
35+
```
7036

71-
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).
37+
4. **Change the config for your preferences**
38+
The config file is located at `config/site.js`
7239

73-
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.
40+
5. **Open the source code and start editing!**
7441

75-
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.
42+
Open the `my-portfolio` directory in your code editor of choice and edit `src/pages/index.js`. Save your changes and the browser will update in real time!
7643

77-
9. **`LICENSE`**: Gatsby is licensed under the MIT license.
44+
```sh
45+
gatsby develop
46+
```
47+
Your site is now running at `http://localhost:8000`!
7848

79-
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).**
49+
_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)._
8050
81-
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.
8251
83-
12. **`README.md`**: A text file containing useful reference information about your project.
52+
## Modify GitHub Query
8453
85-
## 🎓 Learning Gatsby
54+
Heads up! GitHub's GraphQL Explorer makes use of your real, live, production data.
8655

87-
Looking for more guidance? Full documentation for Gatsby lives [on the website](https://www.gatsbyjs.org/). Here are some places to start:
56+
[GitHub GraphQL API](https://developer.github.com/v4/explorer/?variables=%20%7B%0A%20%20%20%22number_of_repos%22%3A%203%0A%7D&query=query%28%24number_of_repos%3AInt%21%29%20%7B%0A%20%20viewer%20%7B%0A%20%20%20%20name%0A%20%20%20%20%20repositories%28last%3A%20%24number_of_repos%29%20%7B%0A%20%20%20%20%20%20%20nodes%20%7B%0A%20%20%20%20%20%20%20%20%20name%0A%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%7D%0A%20%20%20%7D%0A%7D%0A)
8857

89-
- **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.
58+
## Deploy
9059

91-
- **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.
60+
[![Deploy to Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/lundgren2/gatsby-starter-github-api)
9261

93-
## 💫 Deploy
62+
_Note: Don't forget to add your ENV variable to netlify: https://www.netlify.com/docs/continuous-deployment/#environment-variables_
9463
95-
[![Deploy to Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/gatsbyjs/gatsby-starter-default)
64+
## Credits
9665
97-
<!-- AUTO-GENERATED-CONTENT:END -->
66+
- [gatsby-source-github-api](https://www.gatsbyjs.org/packages/gatsby-source-github-api)
67+
- [github-buttons](https://github.com/ntkme/github-buttons)

Diff for: config/site.js

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
module.exports = {
2+
title: `Gatsby Starter Github API`,
3+
description: `Kick off your next, great Gatsby project with this Github source starter.`,
4+
author: `@lundgren2`,
5+
siteUrl: `https://gatsby-starter-github-api.netlify.com`,
6+
githubApiToken: process.env.GITHUB_API_TOKEN,
7+
githubApiQuery: `query ($number_of_repos: Int!) {
8+
viewer {
9+
name
10+
avatarUrl
11+
isHireable
12+
resourcePath
13+
repositories(last: $number_of_repos, privacy: PUBLIC, orderBy: { field: STARGAZERS, direction:ASC } ) {
14+
nodes {
15+
name
16+
description
17+
homepageUrl
18+
forkCount
19+
createdAt
20+
updatedAt
21+
resourcePath
22+
languages(last: 1, orderBy: { field: SIZE, direction:ASC } ) {
23+
edges {
24+
node {
25+
name
26+
color
27+
}
28+
}
29+
}
30+
licenseInfo {
31+
name
32+
}
33+
stargazers {
34+
totalCount
35+
}
36+
}
37+
}
38+
}
39+
}`,
40+
githubApiVariables: {
41+
number_of_repos: 12,
42+
},
43+
}

Diff for: gatsby-browser.js

-7
This file was deleted.

Diff for: gatsby-config.js

+16-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
1+
require("dotenv").config()
2+
3+
const config = require("./config/site")
4+
15
module.exports = {
26
siteMetadata: {
3-
title: `Gatsby Default Starter`,
4-
description: `Kick off your next, great Gatsby project with this default starter. This barebones starter ships with the main Gatsby configuration files you might need.`,
5-
author: `@gatsbyjs`,
7+
siteUrl: config.siteUrl,
8+
title: config.title,
9+
description: config.description,
10+
author: config.author,
611
},
712
plugins: [
813
`gatsby-plugin-react-helmet`,
14+
{
15+
resolve: `gatsby-source-github-api`,
16+
options: {
17+
token: config.githubApiToken,
18+
graphQLQuery: config.githubApiQuery,
19+
variables: config.githubApiVariables,
20+
},
21+
},
922
{
1023
resolve: `gatsby-source-filesystem`,
1124
options: {

Diff for: gatsby-node.js

-7
This file was deleted.

Diff for: gatsby-ssr.js

-7
This file was deleted.

Diff for: package.json

+9-1
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,26 @@
55
"version": "0.1.0",
66
"author": "Kyle Mathews <[email protected]>",
77
"dependencies": {
8+
"@githubprimer/octicons-react": "^8.5.0",
89
"gatsby": "^2.6.0",
910
"gatsby-image": "^2.1.0",
1011
"gatsby-plugin-manifest": "^2.1.1",
1112
"gatsby-plugin-offline": "^2.1.1",
1213
"gatsby-plugin-react-helmet": "^3.0.12",
14+
"gatsby-plugin-react-svg": "^2.1.1",
1315
"gatsby-plugin-sharp": "^2.0.37",
16+
"gatsby-plugin-typography": "^2.2.13",
1417
"gatsby-source-filesystem": "^2.0.37",
18+
"gatsby-source-github-api": "^0.1.0",
1519
"gatsby-transformer-sharp": "^2.1.19",
1620
"prop-types": "^15.7.2",
1721
"react": "^16.8.6",
1822
"react-dom": "^16.8.6",
19-
"react-helmet": "^5.2.1"
23+
"react-github-btn": "^1.0.5",
24+
"react-helmet": "^5.2.1",
25+
"react-typography": "^0.16.19",
26+
"typography": "^0.16.19",
27+
"typography-theme-github": "^0.16.19"
2028
},
2129
"devDependencies": {
2230
"prettier": "^1.17.1"

Diff for: src/components/avatar.js

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import React from "react"
2+
3+
const Avatar = ({ img }) => {
4+
return (
5+
<div
6+
style={{
7+
width: 125,
8+
height: 125,
9+
display: "flex",
10+
position: "relative",
11+
overflow: "hidden",
12+
fontSize: "1.25rem",
13+
alignItems: "center",
14+
flexShrink: 0,
15+
userSelect: "none",
16+
borderRadius: "50%",
17+
justifyContent: "center",
18+
}}
19+
>
20+
<img
21+
src={img}
22+
alt="avatar"
23+
style={{
24+
width: "100%",
25+
height: "100%",
26+
textAlign: "center",
27+
objectFit: "cover",
28+
margin: 0,
29+
}}
30+
/>
31+
</div>
32+
)
33+
}
34+
35+
export default Avatar

Diff for: src/components/header.js

-42
This file was deleted.

Diff for: src/components/image.js

+7-14
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,24 @@ import React from "react"
22
import { StaticQuery, graphql } from "gatsby"
33
import Img from "gatsby-image"
44

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.dev/gatsby-image
13-
* - `StaticQuery`: https://gatsby.dev/staticquery
14-
*/
15-
165
const Image = () => (
176
<StaticQuery
187
query={graphql`
198
query {
20-
placeholderImage: file(relativePath: { eq: "gatsby-astronaut.png" }) {
9+
placeholderImage: file(relativePath: { eq: "github-gatsby.png" }) {
2110
childImageSharp {
22-
fluid(maxWidth: 300) {
11+
fluid(maxWidth: 960) {
2312
...GatsbyImageSharpFluid
2413
}
2514
}
2615
}
2716
}
2817
`}
29-
render={data => <Img fluid={data.placeholderImage.childImageSharp.fluid} />}
18+
render={data => (
19+
<a href="https://github.com/lundgren2/gatsby-starter-github-api">
20+
<Img fluid={data.placeholderImage.childImageSharp.fluid} />
21+
</a>
22+
)}
3023
/>
3124
)
3225
export default Image

0 commit comments

Comments
 (0)