Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into kosvrouvas-patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
gatsbybot committed Apr 5, 2020
2 parents da98b4e + b0c2b11 commit 32e9b32
Show file tree
Hide file tree
Showing 88 changed files with 9,122 additions and 5,587 deletions.
74 changes: 61 additions & 13 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ jobs:
- run-benchmark:
working_directory: benchmarks/markdown_id
NUM_PAGES: "512"
BENCHMARK_CONTENT_SOURCE: MDX
BENCHMARK_CONTENT_SOURCE: MARKDOWN
BENCHMARK_REPO_NAME: gatsbyjs/gatsby/benchmarks/markdown_id
BENCHMARK_SITE_TYPE: BLOG

Expand All @@ -457,7 +457,7 @@ jobs:
- run-benchmark:
working_directory: benchmarks/markdown_id
NUM_PAGES: "4096"
BENCHMARK_CONTENT_SOURCE: MDX
BENCHMARK_CONTENT_SOURCE: MARKDOWN
BENCHMARK_REPO_NAME: gatsbyjs/gatsby/benchmarks/markdown_id
BENCHMARK_SITE_TYPE: BLOG

Expand All @@ -468,7 +468,7 @@ jobs:
- run-benchmark:
working_directory: benchmarks/markdown_id
NUM_PAGES: "8192"
BENCHMARK_CONTENT_SOURCE: MDX
BENCHMARK_CONTENT_SOURCE: MARKDOWN
BENCHMARK_REPO_NAME: gatsbyjs/gatsby/benchmarks/markdown_id
BENCHMARK_SITE_TYPE: BLOG

Expand All @@ -479,7 +479,7 @@ jobs:
- run-benchmark:
working_directory: benchmarks/markdown_id
NUM_PAGES: "32768"
BENCHMARK_CONTENT_SOURCE: MDX
BENCHMARK_CONTENT_SOURCE: MARKDOWN
BENCHMARK_REPO_NAME: gatsbyjs/gatsby/benchmarks/markdown_id
BENCHMARK_SITE_TYPE: BLOG

Expand All @@ -490,7 +490,7 @@ jobs:
- run-benchmark:
working_directory: benchmarks/markdown_slug
NUM_PAGES: "512"
BENCHMARK_CONTENT_SOURCE: MDX
BENCHMARK_CONTENT_SOURCE: MARKDOWN
BENCHMARK_REPO_NAME: gatsbyjs/gatsby/benchmarks/markdown_slug
BENCHMARK_SITE_TYPE: BLOG

Expand All @@ -501,7 +501,7 @@ jobs:
- run-benchmark:
working_directory: benchmarks/markdown_slug
NUM_PAGES: "4096"
BENCHMARK_CONTENT_SOURCE: MDX
BENCHMARK_CONTENT_SOURCE: MARKDOWN
BENCHMARK_REPO_NAME: gatsbyjs/gatsby/benchmarks/markdown_slug
BENCHMARK_SITE_TYPE: BLOG

Expand All @@ -512,7 +512,7 @@ jobs:
- run-benchmark:
working_directory: benchmarks/markdown_slug
NUM_PAGES: "8192"
BENCHMARK_CONTENT_SOURCE: MDX
BENCHMARK_CONTENT_SOURCE: MARKDOWN
BENCHMARK_REPO_NAME: gatsbyjs/gatsby/benchmarks/markdown_slug
BENCHMARK_SITE_TYPE: BLOG

Expand All @@ -523,7 +523,7 @@ jobs:
- run-benchmark:
working_directory: benchmarks/markdown_slug
NUM_PAGES: "32768"
BENCHMARK_CONTENT_SOURCE: MDX
BENCHMARK_CONTENT_SOURCE: MARKDOWN
BENCHMARK_REPO_NAME: gatsbyjs/gatsby/benchmarks/markdown_slug
BENCHMARK_SITE_TYPE: BLOG

Expand All @@ -534,7 +534,7 @@ jobs:
- run-benchmark:
working_directory: benchmarks/markdown_table
NUM_PAGES: "512"
BENCHMARK_CONTENT_SOURCE: MDX
BENCHMARK_CONTENT_SOURCE: MARKDOWN
BENCHMARK_REPO_NAME: gatsbyjs/gatsby/benchmarks/markdown_table
BENCHMARK_SITE_TYPE: BLOG

Expand All @@ -545,7 +545,7 @@ jobs:
- run-benchmark:
working_directory: benchmarks/markdown_table
NUM_PAGES: "4096"
BENCHMARK_CONTENT_SOURCE: MDX
BENCHMARK_CONTENT_SOURCE: MARKDOWN
BENCHMARK_REPO_NAME: gatsbyjs/gatsby/benchmarks/markdown_table
BENCHMARK_SITE_TYPE: BLOG

Expand All @@ -556,7 +556,7 @@ jobs:
- run-benchmark:
working_directory: benchmarks/markdown_table
NUM_PAGES: "8192"
BENCHMARK_CONTENT_SOURCE: MDX
BENCHMARK_CONTENT_SOURCE: MARKDOWN
BENCHMARK_REPO_NAME: gatsbyjs/gatsby/benchmarks/markdown_table
BENCHMARK_SITE_TYPE: BLOG

Expand All @@ -565,12 +565,56 @@ jobs:
- image: "circleci/node:12"
steps:
- run-benchmark:
working_directory: benchmarks/markdown_table/benchmarks/markdown_table
working_directory: benchmarks/markdown_table
NUM_PAGES: "32768"
BENCHMARK_CONTENT_SOURCE: MDX
BENCHMARK_CONTENT_SOURCE: MARKDOWN
BENCHMARK_REPO_NAME: gatsbyjs/gatsby/benchmarks/markdown_table
BENCHMARK_SITE_TYPE: BLOG

benchmark_mdx_512:
docker:
- image: "circleci/node:12"
steps:
- run-benchmark:
working_directory: benchmarks/mdx
NUM_PAGES: "512"
BENCHMARK_CONTENT_SOURCE: MDX
BENCHMARK_REPO_NAME: gatsbyjs/gatsby/benchmarks/mdx
BENCHMARK_SITE_TYPE: BLOG

benchmark_mdx_4096:
docker:
- image: "circleci/node:12"
steps:
- run-benchmark:
working_directory: benchmarks/mdx
NUM_PAGES: "4096"
BENCHMARK_CONTENT_SOURCE: MDX
BENCHMARK_REPO_NAME: gatsbyjs/gatsby/benchmarks/mdx
BENCHMARK_SITE_TYPE: BLOG

benchmark_mdx_8192:
docker:
- image: "circleci/node:12"
steps:
- run-benchmark:
working_directory: benchmarks/mdx
NUM_PAGES: "8192"
BENCHMARK_CONTENT_SOURCE: MDX
BENCHMARK_REPO_NAME: gatsbyjs/gatsby/benchmarks/mdx
BENCHMARK_SITE_TYPE: BLOG

benchmark_mdx_32768:
docker:
- image: "circleci/node:12"
steps:
- run-benchmark:
working_directory: benchmarks/mdx
NUM_PAGES: "32768"
BENCHMARK_CONTENT_SOURCE: MDX
BENCHMARK_REPO_NAME: gatsbyjs/gatsby/benchmarks/mdx
BENCHMARK_SITE_TYPE: BLOG

workflows:
version: 2

Expand All @@ -588,6 +632,10 @@ workflows:
- benchmark_markdown_table_4096
- benchmark_markdown_table_8192
- benchmark_markdown_table_32768
- benchmark_mdx_512
- benchmark_mdx_4096
- benchmark_mdx_8192
- benchmark_mdx_32768
triggers:
- schedule:
cron: 22 16 * * *
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The standard interface for running a benchmark is:
cd {benchmark directory}
export NUM_PAGES={n}
npm install
gatsby build
npm run build / gatsby build
```

If a specific benchmark needs to perform some code generation (e.g. `markdown_id`),
Expand Down
1 change: 1 addition & 0 deletions benchmarks/mdx/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
12
24 changes: 6 additions & 18 deletions benchmarks/mdx/README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,13 @@
# MDX Benchmark

This Gatsby site generates MDX files and downloads sample images on postinstall and places them in `src/articles`. In order for that to work, the env var `BENCHMARK_LEVEL` needs to be set to a number when you call `yarn` to install, so:
Benchmark for MDX pages.
Mock data is generated during the dependency installation step.
The number of pages generated is read from `NUM_PAGES=` (defaults to `512`).

```
BENCHMARK_LEVEL=1 yarn
gatsby build
$ export NUM_PAGES=1024
$ yarn install # or npm install
$ gatsby build # or npm run build
```

If you see "Error: Expected an integer but received: " then you did not set the level env var.

This will not use an external source for data while building, but will download some remote images while installing.

# Levels

The `BENCHMARK_LEVEL` is the amount of times to multiply 512 by 2. The level is used to determine how many articles to generate.

Level 1 = 512

Level 2 = 1024

Level 3 = 2048

etc.
8 changes: 5 additions & 3 deletions benchmarks/mdx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
"build:send": "cross-env BENCHMARK_REPORTING_URL=true gatsby build",
"develop": "gatsby develop",
"format": "prettier --write \"**/*.{js,jsx,json,md}\"",
"postinstall": "npx willit --type=\"mdx\" --level=${BENCHMARK_LEVEL}",
"postinstall": "del-cli src/articles && gatsby clean && willit --type=mdx --num-pages=${NUM_PAGES:-512}",
"start": "npm run develop",
"serve": "gatsby serve"
},
"resolutions": {
"sharp": "0.25.1"
},
"dependencies": {
"del-cli": "^3.0.0",
"@mdx-js/mdx": "^1.5.7",
"@mdx-js/react": "^1.5.7",
"dotenv": "^8.2.0",
Expand All @@ -34,11 +35,12 @@
"devDependencies": {
"cross-env": "^7.0.0",
"gatsby-plugin-benchmark-reporting": "*",
"prettier": "^1.19.1"
"prettier": "^1.19.1",
"willit": "*"
},
"repository": {
"type": "git",
"url": "https://github.com/gatsbyjs/benchmark/mdx"
"url": "https://github.com/gatsbyjs/gatsby/tree/master/benchmarks/mdx"
},
"bugs": {
"url": "https://github.com/gatsbyjs/gatsby/issues"
Expand Down
6 changes: 3 additions & 3 deletions benchmarks/source-contentful/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ BENCHMARK_DATASOURCE_LOCAL_PATH='/path/to/benchmark/_dataset
BENCHMARK_SITE_ID='site1'

# Required for `yarn setup` script only
CONTENTFUL_MANAGEMENT_TOKEN=''
BENCHMARK_CONTENTFUL_MANAGEMENT_TOKEN=''

# Required for `yarn build`
CONTENTFUL_SPACE_ID=''
CONTENTFUL_ACCESS_TOKEN=''
BENCHMARK_CONTENTFUL_SPACE_ID=''
BENCHMARK_CONTENTFUL_ACCESS_TOKEN=''
1 change: 1 addition & 0 deletions benchmarks/source-contentful/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
12
4 changes: 2 additions & 2 deletions benchmarks/source-contentful/bin/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ if (!fs.existsSync(inputDir)) {

const locale = `en-US`
const contentfulConfig = {
spaceId: process.env.CONTENTFUL_SPACE_ID,
managementToken: process.env.CONTENTFUL_MANAGEMENT_TOKEN,
spaceId: process.env.BENCHMARK_CONTENTFUL_SPACE_ID,
managementToken: process.env.BENCHMARK_CONTENTFUL_MANAGEMENT_TOKEN,
}

const { spaceId, managementToken } = contentfulConfig
Expand Down
6 changes: 3 additions & 3 deletions benchmarks/source-contentful/gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ require("dotenv").config({
})

const contentfulConfig = {
spaceId: process.env.CONTENTFUL_SPACE_ID,
accessToken: process.env.CONTENTFUL_ACCESS_TOKEN,
host: process.env.CONTENTFUL_HOST,
spaceId: process.env.BENCHMARK_CONTENTFUL_SPACE_ID,
accessToken: process.env.BENCHMARK_CONTENTFUL_ACCESS_TOKEN,
host: process.env.BENCHMARK_CONTENTFUL_HOST,
}

const { spaceId, accessToken } = contentfulConfig
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/source-datocms/.env.example
Original file line number Diff line number Diff line change
@@ -1 +1 @@
DATOCMS_API_TOKEN=
BENCHMARK_DATOCMS_API_TOKEN=
1 change: 1 addition & 0 deletions benchmarks/source-datocms/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
12
2 changes: 1 addition & 1 deletion benchmarks/source-datocms/gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = {
{
resolve: `gatsby-source-datocms`,
options: {
apiToken: process.env.DATOCMS_API_TOKEN,
apiToken: process.env.BENCHMARK_DATOCMS_API_TOKEN,
previewMode: false,
disableLiveReload: false,
apiUrl: `https://site-api.datocms.com`,
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/source-drupal/.env.example
Original file line number Diff line number Diff line change
@@ -1 +1 @@
GATSBY_DRUPAL_BASE_URL=
BENCHMARK_DRUPAL_BASE_URL=
1 change: 1 addition & 0 deletions benchmarks/source-drupal/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
12
2 changes: 1 addition & 1 deletion benchmarks/source-drupal/gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = {
{
resolve: `gatsby-source-drupal`,
options: {
baseUrl: process.env.GATSBY_DRUPAL_BASE_URL,
baseUrl: process.env.BENCHMARK_DRUPAL_BASE_URL,
// Auth needed for POST
},
},
Expand Down
1 change: 1 addition & 0 deletions benchmarks/source-wordpress/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
12
2 changes: 1 addition & 1 deletion benchmarks/source-wordpress/gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = {
{
resolve: `gatsby-source-wordpress-experimental`,
options: {
url: process.env.WPGRAPHQL_URL,
url: process.env.BENCHMARK_WPGRAPHQL_URL,
type: {
Post: {
limit: process.env.NODE_ENV === `development` ? 50 : false,
Expand Down
41 changes: 41 additions & 0 deletions docs/blog/100days/use-themes/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
title: Challenge 14 - Rapidly Build Sites with Gatsby Themes
date: 2020-04-03
author: "Hashim Warren"
excerpt: "Learn how to use a Gatsby Theme in your project"
tags: ["learning-to-code", "100-Days-of-Gatsby"]
---

_Gatsby was named the [#1 new technology to learn in 2020](https://www.cnbc.com/2019/12/02/10-hottest-tech-skills-that-could-pay-off-most-in-2020-says-new-report.html)!_

_To help you learn about Gatsby and our ecosystem, we invite you to take the #100DaysOfGatsby challenge! If you are new to Gatsby, you can follow along with our beginner-friendly weekly prompts. Or if you are familiar with Gatsby and want to go deeper, we invite you to [build your first Gatsby Theme](/docs/themes/building-themes/)._

_Learn more about [#100DaysOfGatsby here](/blog/100days)!_

## Challenge 14: Spin Up a New Site with a Gatsby Theme

For the final two challenges you will explore using and creating Gatsby Themes!

So far you’ve created a Gatsby site from scratch, and added features for usage on a single site. Gatsby Themes opens up the possibility to leverage good ideas from the Gatsby ecosystem, and share your own configurations and designs. You can think of Gatsby Themes as handy website kits that can be shared, customized, and stacked together.

Before you dive into creating a theme, our resources below will point you to the philosophy behind Gatsby Themes and common use cases. Then we’ll show you how to use a theme in your poject. And next week you'll explore creating your own theme!

### Gatsby Theme Usage Resources

#### Theme Philosophy

[Why Gatsby Themes](/blog/2019-01-31-why-themes) Kyle Mathews gives a short intro into Gatsby Themes, and why this functionality was added to Gatsby

[What are Gatsby Themes](https://youtu.be/LBpNwUU3QVI) Chris Biscardi presents a high level view of how themes work in Gatsby

[Using Theme for Distributed Docs](/blog/2019-07-03-using-themes-for-distributed-docs/) The Apollo team explains how and why they use Gatsby Themes

#### Theme Usage

[Discover a Gatsby Theme](/plugins/?=gatsby-theme) Browse Gatsby’s plugin repository to find the right theme for your project

[Use a Gatsby Theme](/docs/themes/using-a-gatsby-theme/) Step-by-step guide to the conventions of Gatsby Theme usage (hint: "shadow and extend", don’t fork 🙂 )

### What to Do If You Need Help

If you get stuck during the challenge, you can ask for help from the [Gatsby community](/contributing/community/) and the [ASKGatsbyJS](https://twitter.com/AskGatsbyJS) Twitter account. You can find fellow Gatsby Developers on [Discord](https://discordapp.com/invite/gatsby), [Reddit](https://www.reddit.com/r/gatsbyjs/), [Spectrum](https://spectrum.chat/gatsby-js), and [Dev](https://dev.to/t/gatsby).
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 32e9b32

Please sign in to comment.