Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from gatsbyjs:master #540

Merged
merged 47 commits into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
f2f0acf
chore(gatsby-telemetry): upgrade git-up (#36358)
pieh Aug 11, 2022
5b6f1f6
chore(gatsby): upgrade multer (#36359)
pieh Aug 11, 2022
bc80c23
chore: Add note about rehype-slug-custom-id
LekoArts Aug 11, 2022
a9132a5
chore(deps): update sharp (#35539)
renovate[bot] Aug 11, 2022
25fb9d1
chore: Fix pipeline tests (#36363)
LekoArts Aug 11, 2022
7fcf580
fix(gatsby): e.remove() is not a function when using Gatsby Head API …
marvinjude Aug 11, 2022
f990e08
fix(test): clear and close lmdb after each test suite (#36343)
pieh Aug 11, 2022
2b4ff76
fix(gatsby): Make runtime error overlay work in non-v8 browsers (#36365)
tyhopp Aug 11, 2022
ab55e4e
chore: Update `got` (#36366)
LekoArts Aug 11, 2022
f664ad2
feat(gatsby): Telemetry tracking for Head API (#36352)
marvinjude Aug 11, 2022
f1a45e7
chore(release): Publish next pre-minor
marvinjude Aug 11, 2022
fe1d2e1
chore(gatsby): convert babel-loaders to typescript (#36318)
Kornil Aug 11, 2022
df76277
chore(release): Publish next
tyhopp Aug 12, 2022
8bad1a7
chore: Remove unused deps (#36368)
LekoArts Aug 12, 2022
3dfc1ec
fix(gatsby-plugin-image): Make onLoad callback work on first load (#3…
tyhopp Aug 12, 2022
48b4011
chore(docs): Remove outdated image doc (#36376)
LekoArts Aug 12, 2022
3b6b975
chore(release): Publish next
tyhopp Aug 15, 2022
b3960c8
chore(deps): update starters and examples to ^18.0.17 (#36384)
renovate[bot] Aug 15, 2022
4c752d1
fix(gatsby-script): Reach router import (#36385)
tyhopp Aug 15, 2022
c5ad03a
chore(release): Publish next
tyhopp Aug 15, 2022
0744cfd
chore(docs): Add fragments to GraphQL typegen (#36386)
LekoArts Aug 15, 2022
65739fc
fix(gatsby-plugin-mdx): Hashing and pluginOptions (#36387)
LekoArts Aug 15, 2022
ee8df07
chore(release): Publish next
LekoArts Aug 15, 2022
28cfade
chore(gatsby): upgrade @pmmmwh/react-refresh-webpack-plugin (#36360)
pieh Aug 15, 2022
de153b6
chore(docs): MDX v2 (#35893)
axe312ger Aug 16, 2022
14792cf
chore(docs): Release Notes for 4.21 (#36372)
marvinjude Aug 16, 2022
d59e7b6
chore(gatsby): convert sanitize-node to typescript (#36327)
Kornil Aug 16, 2022
b92bd7a
chore(changelogs): update changelogs (#36397)
gatsbybot Aug 17, 2022
e477938
fix(deps): update starters and examples - gatsby (#36396)
renovate[bot] Aug 17, 2022
6e4a0de
chore: pin xstate (#36398)
pieh Aug 17, 2022
57602fe
chore(docs): Remove outdated note on compatibility with with `react-h…
marvinjude Aug 17, 2022
03157e8
chore: add prefixPaths field on IProgram type (#36400)
pieh Aug 17, 2022
977a211
fix(gatsby-cli): preserve verbosity in spawned child processes (#36399)
pieh Aug 17, 2022
9d737b6
fix(gatsby): close parcel cache db before clearing cache and retrying…
pieh Aug 18, 2022
a05201e
fix(gatsby): Prevent errors if `Head` has root text node (#36402)
marvinjude Aug 18, 2022
c01806e
chore(release): Publish next
marvinjude Aug 18, 2022
3760a0e
feat(gatsby): Add option to emit TS types during build (#36405)
LekoArts Aug 18, 2022
dc283d7
chore: Use GCS for pipeline tests (#36413)
LekoArts Aug 18, 2022
7b3286c
chore(docs): Add note about query name to MDX
LekoArts Aug 19, 2022
b7b3577
fix(gatsby-plugin-react-helmet): Typo in `onPreInit` warning (#36419)
alexlouden Aug 19, 2022
c92404b
chore(changelogs): update changelogs (#36417)
gatsbybot Aug 19, 2022
77190f4
fix(deps): update starters and examples - gatsby (#36416)
renovate[bot] Aug 19, 2022
2e67161
chore(docs): Update tutorial to Head API (#36378)
marvinjude Aug 19, 2022
b361081
chore(gatsby): drop eslint-plugin-graphql (#36364)
pieh Aug 19, 2022
240dfac
chore: update using-image-processing example (#36421)
pieh Aug 19, 2022
8043d7e
feat(docs): add webiny to headless cms list (#36388)
endymion1818 Aug 19, 2022
a21510e
docs: plugin image / image cdn (#36423)
TylerBarnes Aug 22, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion docs/docs/glossary/mdx.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const Figure = props => {
Now you can import this component into your Markdown document.

```markdown
import { Figure } from './components/Figure';
import { Figure } from "./components/Figure"

# Hello world!

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/glossary/server-side-rendering.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ Instead of purely server-side rendering, Gatsby uses the same APIs to create sta

- [Why server-side render?](/blog/2019-04-02-behind-the-scenes-what-makes-gatsby-great/#why-server-side-render) from _Behind the Scenes: What makes Gatsby Great_

- [Search Engine Optimization (SEO) and Social Sharing Cards with Gatsby](/tutorial/seo-and-social-sharing-cards-tutorial/#reach-skip-nav)
- [Adding an SEO Component](/docs/how-to/adding-common-features/adding-seo-component/)

- [What is a Static Site Generator?](/docs/glossary/static-site-generator/#what-is-a-static-site-generator) from the Gatsby docs
22 changes: 13 additions & 9 deletions docs/docs/how-to/images-and-media/using-gatsby-plugin-image.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,21 @@ module.exports = {

## Using images from a CMS or CDN

Many source plugins have native support for `gatsby-plugin-image`, with images served directly from a content delivery network (CDN). This means that builds are faster, because there is no need to download images and process them locally. The query syntax varies according to the plugin, as do the supported transformation features and image formats. Make sure you update to the latest version of the source plugin to ensure there is support. For plugins that are not in this list you can use [dynamic images from `gatsby-transformer-sharp`](#dynamic-images).
### Gatsby Cloud Image CDN

### Source plugins
Image CDN is Gatsby Clouds image hosting and transformation service. It speeds up your build times by deferring image downloading and processing until the first user requests an image. Image CDN also speeds up your frontend performance by serving CDN hosted images on the same domain as your Gatsby Cloud site. In our testing this can shave up to 300ms off of frontend page load times and as a result improve your lighthouse scores.

These source plugins support using `gatsby-plugin-image` with images served from their CDN.
For more information on what Image CDN is, how to use it, and what the platform limits are, visit the [Gatsby Cloud knowledge base article on "What Is Image CDN?"](https://support.gatsbyjs.com/hc/en-us/articles/4426379634835-What-is-Image-CDN-). To learn which source plugins currently support it and how to enable and use Image CDN on Gatsby Cloud take a look at the ["How-to Enable Image CDN" article](https://support.gatsbyjs.com/hc/en-us/articles/4426393233171).

For all supported source plugins, the query syntax and feature-set is identical. Check your source plugin's documentation or the [Gatsby Cloud knowledge base article on "Configuring source plugins for Image CDN"](https://support.gatsbyjs.com/hc/en-us/articles/4522338898579-Configuring-Source-Plugins-for-Image-CDN) for more info.

### Source plugins with their own CDN

Many source plugins have native support for `gatsby-plugin-image`, with images served directly from that CMS's content delivery network (CDN). This means that builds are faster than local images because there is no need to download images and process them. While this is faster for builds, it isn't as performant on the frontend as [Gatsby Cloud's Image CDN](#gatsby-cloud-image-cdn) due to images being served from a different domain than the domain your site is hosted on.

The query syntax varies according to the plugin, as do the supported transformation features and image formats. Make sure you update to the latest version of the source plugin to ensure there is support. For plugins that are not in this list you can use [dynamic images from `gatsby-transformer-sharp`](#dynamic-images).

These source plugins support using `gatsby-plugin-image` with images served from their own CDN.

- [AgilityCMS](https://github.com/agility/gatsby-image-agilitycms)
- [Contentful](/plugins/gatsby-source-contentful/#using-the-new-gatsby-image-plugin)
Expand All @@ -247,12 +257,6 @@ These source plugins support using `gatsby-plugin-image` with images served from
- [Sanity](/plugins/gatsby-source-sanity/#using-images)
- [Shopify](https://github.com/gatsbyjs/gatsby-source-shopify-experimental#images)

### Image CDNs

A dedicated image CDN can be used with sources that don't have their own CDN, or where you need more transforms or formats than the CDN offers.

- [imgix](/plugins/@imgix/gatsby/)

### Plugin authors

If you maintain a source plugin or image CDN, there is a toolkit to help you add support for `gatsby-plugin-image`. See [Adding Gatsby Image support to your plugin](/docs/how-to/plugins-and-themes/adding-gatsby-image-support/) for more details. You can then open a PR to add your plugin to this list.
Expand Down
50 changes: 49 additions & 1 deletion docs/docs/how-to/local-development/graphql-typegen.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ examples:

If you're already using [Gatsby with TypeScript](/docs/how-to/custom-configuration/typescript) and manually typing the results of your queries, you'll learn in this guide how Gatsby's automatic GraphQL Typegen feature can make your life easier. By relying on the types that are generated by Gatsby itself and using autocompletion for GraphQL queries in your IDE you'll be able to write GraphQL queries quicker and safer.

This feature was added in `[email protected]`.
This feature was added in `[email protected]`. By default, this feature is only generating files during `gatsby develop`.

## Prerequisites

Expand Down Expand Up @@ -105,6 +105,54 @@ export const createSchemaCustomization: GatsbyNode["createSchemaCustomization"]

Read the [Customizing the GraphQL schema guide](/docs/reference/graphql-data-layer/schema-customization/) to learn how to explicitly define types in your site or source plugin.

### GraphQL fragments

Fragments allow you to reuse parts of GraphQL queries throughout your site and collocate specific parts of a query to individual files. Learn more about it in the [Using GraphQL fragments guide](/docs/reference/graphql-data-layer/using-graphql-fragments/).

In the context of GraphQL Typegen fragments enable you to have individual TypeScript types for nested parts of your queries since each fragment will be its own TypeScript type. You then can use these types to e.g. type arguments of components consuming the GraphQL data.

Here's an example (also used in [using-graphql-typegen](https://github.com/gatsbyjs/gatsby/tree/master/examples/using-graphql-typegen)) with a `Info` component that gets the `buildTime` as an argument. This `Info` component and its `SiteInformation` fragment is used in the `src/pages/index.tsx` file then:

```tsx:title=src/components/info.tsx
import * as React from "react"
import { graphql } from "gatsby"

// highlight-next-line
const Info = ({ buildTime }: { buildTime?: any }) => {
return (
<p>
Build time: {buildTime}
</p>
)
}

export default Info

// highlight-start
export const query = graphql`
fragment SiteInformation on Site {
buildTime
}
`
// highlight-end
```

```graphql:title=src/pages/index.tsx
# Rest of the page above...

query IndexPage {
site {
...SiteInformation
}
}
```

This way a `SiteInformationFragment` TypeScript type will be created that you can use in the `Info` component:

```tsx:title=src/components/info.tsx
const Info = ({ buildTime }: { buildTime?: Queries.SiteInformationFragment["buildTime"] }) => {}
```

### Tips

- When adding a new key to your GraphQL query you'll need to save the file before new TypeScript types are generated. The autogenerated files are only updated on file saves.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ Any JavaScript data type can be passed in as an option.

The following table lists possible options values and an example plugin that makes use of them.

| Data Type | Sample Value | Example Plugin |
| --------- | -------------------------------- | ---------------------------------------------------------------- |
| Boolean | `true` | [`gatsby-plugin-sharp`](/plugins/gatsby-plugin-sharp/) |
| String | `/src/data/` | [`gatsby-source-filesystem`](/plugins/gatsby-source-filesystem/) |
| Array | `["/about-us/", "/projects/*"]` | [`gatsby-plugin-offline`](/plugins/gatsby-plugin-offline/) |
| Object | `{ default: "./src/layout.js" }` | [`gatsby-plugin-mdx`](/plugins/gatsby-plugin-mdx/) |
| Data Type | Sample Value | Example Plugin |
| --------- | ------------------------------- | ---------------------------------------------------------------- |
| Boolean | `true` | [`gatsby-plugin-sharp`](/plugins/gatsby-plugin-sharp/) |
| String | `/src/data/` | [`gatsby-source-filesystem`](/plugins/gatsby-source-filesystem/) |
| Array | `["/about-us/", "/projects/*"]` | [`gatsby-plugin-offline`](/plugins/gatsby-plugin-offline/) |
| Object | `{ mdxOptions: {} }` | [`gatsby-plugin-mdx`](/plugins/gatsby-plugin-mdx/) |

**Note**: Themes (which are a type of plugin) are able to receive options from a site's `gatsby-config.js` to be used in its `gatsby-config.js` in order to allow themes to be composed together. This is done by exporting the `gatsby-config.js` as a function instead of an object. You can see an example of this in the [`gatsby-theme-blog`](https://github.com/gatsbyjs/themes/tree/master/packages/gatsby-theme-blog) and [`gatsby-theme-blog-core`](https://github.com/gatsbyjs/themes/tree/master/packages/gatsby-theme-blog-core) repositories. Plugins are not capable of this functionality.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Add the plugin as a project dependency in your `package.json` file by running th
npm install gatsby-plugin-sitemap
```

Check the plugin's README file to see if there are any other dependencies that you also need to install. (For example, [`gatsby-plugin-mdx`](/plugins/gatsby-plugin-mdx/) also requires `@mdx-js/mdx` and `@mdx-js/react` to be installed.)
Check the plugin's README file to see if there are any other dependencies that you also need to install. (For example, [`gatsby-plugin-mdx`](/plugins/gatsby-plugin-mdx/) also requires `@mdx-js/react` to be installed.)

### Step 2: Configure the plugin in your `gatsby-config.js` file

Expand Down
4 changes: 2 additions & 2 deletions docs/docs/how-to/querying-data/page-query.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ Consider the following query:

```js:title=src/templates/blog-post.js
export const query = graphql`
query MdxBlogPost {
query {
mdx(title: { eq: "Using a Theme" }) {
id
title
Expand All @@ -168,7 +168,7 @@ In addition to hardcoding an argument directly into the page query, you can pass

```js:title=src/templates/blog-post.js
export const query = graphql`
query MdxBlogPost($title: String) { // highlight-line
query ($title: String) { // highlight-line
mdx(title: {eq: $title}) { // highlight-line
id
title
Expand Down
10 changes: 5 additions & 5 deletions docs/docs/how-to/routing/customizing-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Using MDX, you can replace every HTML element that Markdown renders with a
custom implementation. This allows you to use a set of design system components
when rendering.

```jsx:title=src/components/layout.js
```jsx:title=src/components/layout.jsx
import { MDXProvider } from "@mdx-js/react"
import * as DesignSystem from "your-design-system"

Expand All @@ -28,7 +28,7 @@ export default function Layout({ children }) {
}
```

**Note**: you can also provide your own custom components to the `MDXProvider` that make them globally available while writing MDX. You can find more details about this pattern in the [Importing and Using Components in MDX guide](/docs/mdx/importing-and-using-components#make-components-available-globally-as-shortcodes).
**Note**: You can also provide your own custom components to the `MDXProvider` that make them globally available while writing MDX. You can find more details about this pattern in the [Importing and Using Components in MDX guide](/docs/how-to/routing/mdx#make-components-available-globally-as-shortcodes).

The following components can be customized with the MDXProvider:

Expand Down Expand Up @@ -68,10 +68,10 @@ The following components can be customized with the MDXProvider:

## How does this work?

Components passed to the MDXProvider are used to render the HTML elements
that Markdown creates. It uses
[React's Context API](https://reactjs.org/docs/context.html).
Components passed to the MDXProvider are used to render the HTML elements that Markdown creates. It uses [React's Context API](https://reactjs.org/docs/context.html).

## Related

- [MDX components](https://mdxjs.com/getting-started/)
- [Adding Components to Markdown with MDX](/docs/how-to/routing/mdx/)
- [gatsby-plugin-mdx README](/plugins/gatsby-plugin-mdx)
Loading