Skip to content

Commit

Permalink
change plugin schema testing function to use validation function
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurie committed Oct 20, 2020
2 parents 002ffe2 + f774314 commit fe29c34
Show file tree
Hide file tree
Showing 139 changed files with 1,300 additions and 1,201 deletions.
5 changes: 1 addition & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,7 @@ module.exports = {
// bump to @typescript-eslint/parser started showing Flow related errors in ts(x) files
// so disabling them in .ts(x) files
"flowtype/no-types-missing-file-annotation": "off",
"@typescript-eslint/array-type": [
'error',
{ default: 'generic' },
],
"@typescript-eslint/array-type": ["error", { default: "generic" }],
},
},
],
Expand Down
3 changes: 3 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ contact_links:
- name: Gatsby Discord
url: https://gatsby.dev/discord
about: Ask questions, get help and discuss new things you're building with the Gatsby community
- name: Gatsby Discussions
url: https://github.com/gatsbyjs/gatsby/discussions
about: Have a question or feature request?
- name: AskGatsbyJS Twitter
url: https://twitter.com/AskGatsbyJS
about: The official Twitter account to ask questions and get help with Gatsby
34 changes: 0 additions & 34 deletions .github/ISSUE_TEMPLATE/feature_request.md

This file was deleted.

40 changes: 0 additions & 40 deletions .github/ISSUE_TEMPLATE/question.md

This file was deleted.

25 changes: 13 additions & 12 deletions benchmarks/gabe-csv-markdown/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,22 @@ exports.createPages = async ({ graphql, actions }) => {
})
}

exports.unstable_shouldOnCreateNode = ({ node }) =>
node.internal.type === `GendataCsv`

// Not sure if there is a better way than to create a proxy node for markdown to pick up
// I certainly can't get remark to to pick up csv nodes :(
exports.onCreateNode = ({ node, actions }) => {
const { createNode } = actions

if (node.internal.type === `GendataCsv`) {
createNode({
id: `${node.id}-MarkdownProxy`,
parent: node.id,
internal: {
type: `MarkdownProxy`,
mediaType: "text/markdown",
content: node.articleContent,
contentDigest: node.articleContent,
},
})
}
createNode({
id: `${node.id}-MarkdownProxy`,
parent: node.id,
internal: {
type: `MarkdownProxy`,
mediaType: "text/markdown",
content: node.articleContent,
contentDigest: node.articleContent,
},
})
}
63 changes: 32 additions & 31 deletions benchmarks/gabe-fs-text/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,40 +40,41 @@ exports.createPages = async ({ graphql, actions }) => {
})
}

exports.onCreateNode = ({ node, actions , createNodeId}) => {
if (node.internal.type === "File") {
// Do minimal processing to get some key pieces. This could be gatsby-transformer-text or -html :p
exports.unstable_shouldOnCreateNode = ({ node }) =>
node.internal.type === "File"

const html = fs.readFileSync(node.absolutePath, "utf8")
exports.onCreateNode = ({ node, actions, createNodeId }) => {
// Do minimal processing to get some key pieces. This could be gatsby-transformer-text or -html :p

const base = path.basename(node.absolutePath)
const slug = base.slice(11, -5) // remove date prefix and `..txt` tail
const date = base.slice(0, 10)
const html = fs.readFileSync(node.absolutePath, "utf8")

const offset1 = html.indexOf("<h1>")
const title = html.slice(
offset1 + "<h1>".length,
html.indexOf("</h1>", offset1)
)
const base = path.basename(node.absolutePath)
const slug = base.slice(11, -5) // remove date prefix and `..txt` tail
const date = base.slice(0, 10)

const offset2 = html.indexOf("<blockquote>", offset1)
const description = html.slice(
offset2 + "<blockquote>".length,
html.indexOf("</blockquote>", offset2)
)
const offset1 = html.indexOf("<h1>")
const title = html.slice(
offset1 + "<h1>".length,
html.indexOf("</h1>", offset1)
)

actions.createNode({
id: createNodeId(slug),
slug,
date,
title,
description,
html,
internal: {
type: "Texto",
contentDigest: html,
},
parent: node.id, // Required otherwise the node is not cached and a warm build screws up. TODO: is touchNode faster?
})
}
const offset2 = html.indexOf("<blockquote>", offset1)
const description = html.slice(
offset2 + "<blockquote>".length,
html.indexOf("</blockquote>", offset2)
)

actions.createNode({
id: createNodeId(slug),
slug,
date,
title,
description,
html,
internal: {
type: "Texto",
contentDigest: html,
},
parent: node.id, // Required otherwise the node is not cached and a warm build screws up. TODO: is touchNode faster?
})
}
2 changes: 1 addition & 1 deletion docs/docs/gatsby-lifecycle-apis.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ During the main bootstrap sequence, Gatsby (in this order):
- within this, `createNode` can be called multiple times, which then triggers [onCreateNode](/docs/node-apis/#onCreateNode)
- creates initial GraphQL schema
- runs [resolvableExtensions](/docs/node-apis/#resolvableExtensions) which lets plugins register file types or extensions e.g. [`gatsby-plugin-typescript`](https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-plugin-typescript/src/gatsby-node.js)
- runs [createPages](/docs/node-apis/#createPages) from the gatsby-node.js in the root directory of the project e.g. implemented by [`page-hot-reloader`](https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby/src/bootstrap/page-hot-reloader.js)
- runs [createPages](/docs/node-apis/#createPages) from the gatsby-node.js in the root directory of the project e.g. implemented by [`page-hot-reloader`](https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby/src/bootstrap/page-hot-reloader.ts)
- within this, `createPage` can be called any number of times, which then triggers [onCreatePage](/docs/node-apis/#onCreatePage)
- runs [createPagesStatefully](/docs/node-apis/#createPagesStatefully)
- runs source nodes again and updates the GraphQL schema to include pages this time
Expand Down
Binary file added docs/docs/images/graphcms-query.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/docs/images/graphcms-schema.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions docs/docs/mdx/customizing-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default function Layout({ children }) {
The following components can be customized with the MDXProvider:

<!-- remark lint doesn't realize the pipes in code blocks aren't table markers -->
<!-- prettier-ignore-start -->
<!-- lint ignore table-pipe-alignment -->

| Tag | Name | Syntax |
Expand Down Expand Up @@ -63,6 +64,7 @@ The following components can be customized with the MDXProvider:
| `img` | [Image](https://github.com/syntax-tree/mdast#image) | `![alt](https://mdx-logo.now.sh)` |

<!-- lint enable table-pipe-alignment -->
<!-- prettier-ignore-end -->

## How does this work?

Expand Down
Loading

0 comments on commit fe29c34

Please sign in to comment.