This project is a fork of https://github.com/PokeAPI/api-data, it contains all the Pokeapi JSON files and a gatsby
folder containing the static site and additional data and assets generated using custom scripts and gatsby plugins.
-
Clone the project and install dependencies.
git clone https://github.com/cube5/pokeapi-data
# Navigate to gatsby folder and install dependencies cd gatsby && npm i
-
Seed the
data
folder.Run the
seed
script (seegatsby/package.json
).# You can use the --limit {number} arg to copy just the files you specify npm run seed
-
Upload the images to Coludinary and create references to them in JSON files
This script takes the
pokemon
folder from the folder generated with theseed
script and uploads the necessary sprites to a cloudinary account (you'll need to provide the env keys included in the.env.example
file). Currently the source of those images is Pokestadium.After each uploaded img, the script creates a JSON file inside
data/pokemon-images
containing the uploaded asset url.npm run images
-
Star the project (finally xD)
npm run develop
Your site is now running at
http://localhost:8000
!_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._
A quick look at the important files and directories to undestand what do they do and how the project works.
.
├── src
├── data
├── pokeapi
├── pokemon-images
├── plugins
├── gatsby-source-pokeapi-local
├── scripts
├── seed.js
├── images.js
├── gatsby-config.js
├── gatsby-node.js
-
src/data
: 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”. -
src/data/pokeapi
: This folder remains empty until you run theseed
script, then it contains the necessary json files extracted from the../data/api/v2
folder. -
src/data/pokemon-images
: This folder remains empty until yo run theimages
script, then it contains one JSON file for each pokemon insrc/data/pokeapi/pokemon
(you have to run theseed
script first) with the uploaded images urls so we can use them in the project. -
/plugins/gatsby-source-pokeapi-local
: This is a local gatsby plugin that takes the pokeapi data (src/data/pokeapi
) and create the GraphQL nodes so we can query them in the project with some Gatsby magic. -
/scripts/seed.js
: It takes the pokeapi data from../data/api/v2
folder and copies the indicated files tosrc/data/pokeapi
. During development it only copies a limit of 151 children (you can use the--limit {number}
flag to indicate a different quantity) of each specified folder to avoid memory issues. In the production build it copies everything. It detects the current environment with theNODE_ENV
env variable. -
/scripts/images.js
: It reads thesrc/data/pokeapi/pokemon
folder and uploads an image for each pokemon you have in there, it also generates the JSON files to reference them intosrc/data/pokemon-images
. -
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 for more detail). -
gatsby-node.js
: This is were we query some GraphQL nodes and generate the necessary pages using the templates from thesrc/templates
folder.
Looking for more guidance? Full documentation for Gatsby lives on the website. Here are some places to start:
-
For most developers, we recommend starting with our in-depth tutorial for creating a site with Gatsby. It starts with zero assumptions about your level of ability and walks through every step of the process.
-
To dive straight into code samples, head to our documentation. In particular, check out the Guides, API Reference, and Advanced Tutorials sections in the sidebar.
This project wolud not exist whitout these guys.
Gatsby - REALLY FUCKING FAST
Pokeapi Data - Well, I'm using all their data so this project would not be possible whitout those guys, it contains a BUNCH of data, it is an incredible project and great effort.
Pokedex.org (ideas and inspiration) - Great project
Pokestadium - I'm pokemon sprites they host to upload them to Cloudinary.
CSS Animated Pokeball Codepen by Rau - Awesome css only animated pokeball.
Cloudinary - Great free tier and fast CDN for images.
Zeit's Now - Amazing static hosting.
Zeit's Design - Beautiful components, I'm using a couple of their styles.