You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 20, 2025. It is now read-only.
Most examples in the Gatsby docs and on the web at large focus on leveraging source plugins to manage your data in Gatsby sites. However, source plugins (or even Gatsby nodes) aren't strictly necessary to pull data into a Gatsby site! It's also possible to use an “unstructured data” approach in Gatsby sites, no GraphQL required.
> Note: For our purposes here, “unstructured data” means data “handled outside of Gatsby’s data layer” (we’re using the data directly, and not transforming the data into Gatsby nodes).
## The approach: fetch data and use Gatsby's `createPages` API
9
+
## アプローチ: Gatsby の `createPages` API を使いデータを取得する
10
10
11
-
> _Note_: This example is drawn from an example repo built specifically to model how to use this "unstructured data" approach. [View the full repo on GitHub](https://github.com/jlengstorf/gatsby-with-unstructured-data).
-`createPages`is a [Gatsby Node API](/docs/node-apis/#createPages). It hooks into a certain point in [Gatsby's bootstrap sequence](/docs/gatsby-lifecycle-apis/#bootstrap-sequence).
39
-
-The [`createPage`action](/docs/actions/#createPage) is what actually creates the page.
Using Gatsby's data layer provides the following benefits:
79
+
一方で、GraphQL によるデータ層を導入した場合のメリットもみてみましょう。
80
80
81
-
-Enables you to declaratively specify what data a page component needs, alongside the page component
82
-
-Eliminates frontend data boilerplate — no need to worry about requesting & waiting for data. Just ask for the data you need with a GraphQL query and it’ll show up when you need it
83
-
-Pushes frontend complexity into queries — many data transformations can be done at build-time within your GraphQL queries
84
-
-It’s the perfect data querying language for the often complex/nested data dependencies of modern applications
85
-
-Improves performance by removing data bloat — GraphQL is a big part of why Gatsby is so fast as it enables lazy-loading the exact data in the exact form each view needs
86
-
-Enables you to take advantage of hot reloading when developing; For example, in this post's example "Pokémon" site, if you wanted to add a "see other pokémon" section to the pokémon detail view, you would need to change your `gatsby-node.js`to pass all pokémon to the page, and restart the dev server. In contrast, when using queries, you can add a query and it will hot reload.
-[`gatsby-transformer-sharp`](https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-transformer-sharp) (provides queryable fields for processing your images in a variety of ways including resizing, cropping, and creating responsive images),
94
-
-... the whole Gatsby ecosystem of official and community-created [transformer plugins](/plugins/?=transformer).
Another difficulty added when working with unstructured data is that your data fetching code becomes increasingly hairy when you source directly from multiple locations.
If you're building a small site, one efficient way to build it is to pull in unstructured data as outlined in this guide, using `createPages` API, and then if the site becomes more complex later on, you move on to building more complex sites, or you'd like to transform your data, follow these steps:
100
+
もしあなたが作ろうとしているサイトの規模が小さいものでしたら、このガイドで説明したように `createPages` API を使って「非構造データ」を取り込むことが効率的でしょう。あとでもしサイトが大きくなったり、より複雑なサイトの構築やデータを加工したくなった場合は下記のような手順を実施してください。
101
101
102
-
1.Check out the [Plugin Library](/plugins/)to see if the source plugins and/or transformer plugins you'd like to use already exist
103
-
2.If they don't exist, read the [Plugin Authoring](/docs/creating-plugins/)guide and consider building your own!
0 commit comments