Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into docs-filters
Browse files Browse the repository at this point in the history
  • Loading branch information
gatsbybot committed Jun 11, 2020
2 parents fcda70d + 7afdfce commit d0fd0bf
Show file tree
Hide file tree
Showing 346 changed files with 2,415 additions and 1,163 deletions.
4 changes: 4 additions & 0 deletions benchmarks/source-kontent/.env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
BENCHMARK_KONTENT_PROJECT_ID=4d1eb9ae-c95e-00e1-da99-692832fe675c
BENCHMARK_KONTENT_LANGUAGE_CODENAMES=default
BENCHMARK_KONTENT_MANAGEMENT_KEY=
BENCHMARK_KONTENT_DATASET_SIZE=
70 changes: 70 additions & 0 deletions benchmarks/source-kontent/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Typescript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# dotenv environment variable files
.env.development
.env.production

# gatsby files
.cache/
public

# Mac files
.DS_Store

# Yarn
yarn-error.log
.pnp/
.pnp.js
# Yarn Integrity file
.yarn-integrity
4 changes: 4 additions & 0 deletions benchmarks/source-kontent/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.cache
package.json
package-lock.json
public
7 changes: 7 additions & 0 deletions benchmarks/source-kontent/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"endOfLine": "lf",
"semi": false,
"singleQuote": false,
"tabWidth": 2,
"trailingComma": "es5"
}
21 changes: 21 additions & 0 deletions benchmarks/source-kontent/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 gatsbyjs

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
7 changes: 7 additions & 0 deletions benchmarks/source-kontent/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Kontent Will it Build Example

Example site for Kontent as a source for "Will It Build".
Should/Will be generalized into e.g. a theme.

Queries the title, body and a cover image from Kontent. Creates pages for that and displays those three things as "Articles".
Those individual article pages and the homepage share a common "Layout" component (in src/components) that can be swapped (layout_1.js and layout_2.js) to simulate a code change in multiple pages.
1 change: 1 addition & 0 deletions benchmarks/source-kontent/gatsby-browser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "./styles.css"
23 changes: 23 additions & 0 deletions benchmarks/source-kontent/gatsby-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
require("dotenv").config({
path: `.env.${process.env.NODE_ENV}`,
})


module.exports = {
siteMetadata: {
siteTitle: `Gatsby Kontent Benchmark`,
},
plugins: [
`gatsby-plugin-benchmark-reporting`,
`gatsby-plugin-sharp`,
`gatsby-transformer-sharp`,
{
resolve: '@kentico/gatsby-source-kontent',
options: {
projectId: process.env.BENCHMARK_KONTENT_PROJECT_ID, // Fill in your Project ID
languageCodenames: process.env.BENCHMARK_KONTENT_LANGUAGE_CODENAMES && process.env.BENCHMARK_KONTENT_LANGUAGE_CODENAMES.split(',')
},
},
`@rshackleton/gatsby-transformer-kontent-image`,
],
}
31 changes: 31 additions & 0 deletions benchmarks/source-kontent/gatsby-node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
exports.createPages = async ({ actions, graphql, reporter }) => {
const { createPage } = actions

const result = await graphql(`
{
articles: allKontentItemArticle {
nodes {
elements {
slug {
value
}
}
}
}
}
`)

if (result.errors) {
reporter.panicOnBuild(result.errors)
}

result.data.articles.nodes.map(article => {
createPage({
path: "/" + article.elements.slug.value,
component: require.resolve(`./src/templates/article.js`),
context: {
slug: article.elements.slug.value,
}
})
})
}
41 changes: 41 additions & 0 deletions benchmarks/source-kontent/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "kontent-gatsby-benchmark",
"description": "Example site for Kontent as a source for \"Will It Build\"",
"version": "0.1.0",
"license": "MIT",
"scripts": {
"build": "gatsby build",
"build:send": "cross-env BENCHMARK_REPORTING_URL=true gatsby build",
"develop": "gatsby develop",
"format": "prettier --write \"**/*.{js,jsx,json,md}\"",
"start": "npm run develop",
"serve": "gatsby serve",
"data-update": "cross-env NODE_ENV=production node update-article.js"
},
"dependencies": {
"@kentico/gatsby-source-kontent": "^6.0.1",
"@rshackleton/gatsby-transformer-kontent-image": "^2.0.0",
"dotenv": "^8.2.0",
"gatsby": "^2.19.7",
"gatsby-image": "^2.2.40",
"gatsby-plugin-benchmark-reporting": "^0.0.2",
"gatsby-plugin-sharp": "^2.4.5",
"gatsby-transformer-sharp": "^2.3.14",
"react": "^16.12.0",
"react-dom": "^16.12.0"
},
"devDependencies": {
"@kentico/kontent-delivery": "^9.1.1",
"@kentico/kontent-management": "^0.3.19",
"cross-env": "^7.0.0",
"prettier": "^1.19.1",
"rxjs": "^6.5.5"
},
"repository": {
"type": "git",
"url": "https://github.com/gatsbyjs/gatsby-starter-hello-world"
},
"bugs": {
"url": "https://github.com/gatsbyjs/gatsby/issues"
}
}
12 changes: 12 additions & 0 deletions benchmarks/source-kontent/src/components/layout_1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from "react"

const Layout = ({ children }) => (
<>
<header>
<h1>Header A</h1>
</header>
<main>{children}</main>
</>
)

export default Layout
12 changes: 12 additions & 0 deletions benchmarks/source-kontent/src/components/layout_2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from "react"

const Layout = ({ children }) => (
<>
<header>
<h1>Header B</h1>
</header>
<main>{children}</main>
</>
)

export default Layout
42 changes: 42 additions & 0 deletions benchmarks/source-kontent/src/pages/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import React from "react"
import { Link, graphql } from "gatsby"
import Layout from "../components/layout_1"

const Index = ({ data }) => {
return (
<Layout>
{data.site.siteMetadata.siteTitle}
<ul>
{data.articles.nodes.map(article => (
<li>
<Link to={article.elements.slug.value}>{article.elements.title.value}</Link>
</li>
))}
</ul>
</Layout>
)
}

export default Index

export const query = graphql`
{
site {
siteMetadata {
siteTitle
}
}
articles: allKontentItemArticle {
nodes {
elements {
title {
value
}
slug {
value
}
}
}
}
}
`
45 changes: 45 additions & 0 deletions benchmarks/source-kontent/src/templates/article.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import React from "react"
import { graphql, Link } from "gatsby"
import Img from "gatsby-image"
import Layout from "../components/layout_1"

const Article = ({ data }) => {
return (
<Layout>
<Link to="/">Go back to index page</Link>
<div>
<h2>{data.article.elements.title.value}</h2>
{data.article.elements.image.value.length > 0 ? (
<Img fluid={data.article.elements.image.value[0].fluid} />
) : (
<div>Image can't be displayed</div>
)}
<div dangerouslySetInnerHTML={{ __html: data.article.elements.content.value }} />
</div>
</Layout>
)
}

export default Article

export const query = graphql`
query($slug: String!){
article: kontentItemArticle(elements: {slug: {value: {eq: $slug }}}) {
elements {
title{
value
}
content {
value
}
image{
value {
fluid(maxWidth: 960) {
...KontentAssetFluid
}
}
}
}
}
}
`
4 changes: 4 additions & 0 deletions benchmarks/source-kontent/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
main {
max-width: 960px;
margin: 0 auto;
}
Loading

0 comments on commit d0fd0bf

Please sign in to comment.