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 Dec 27, 2022. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+69-3Lines changed: 69 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,10 @@ Source plugin for pulling documents into Gatsby from a Strapi API.
8
8
<summary><strong>Table of contents</strong></summary>
9
9
10
10
-[gatsby-source-strapi](#gatsby-source-strapi)
11
-
-[Install](#installing-the-plugin)
11
+
-[Installing the plugin](#installing-the-plugin)
12
+
-[Using yarn](#using-yarn)
13
+
-[Or using NPM](#or-using-npm)
14
+
-[Setting up the plugin](#setting-up-the-plugin)
12
15
-[Basic usage](#basic-usage)
13
16
-[Advanced usage](#advanced-usage)
14
17
-[Deep queries populate](#deep-queries-populate)
@@ -17,7 +20,14 @@ Source plugin for pulling documents into Gatsby from a Strapi API.
17
20
-[Rich text field](#rich-text-field)
18
21
-[Components](#components)
19
22
-[Dynamic zones](#dynamic-zones)
23
+
-[Internationalization](#internationalization)
20
24
-[Gatsby cloud and preview environment setup](#gatsby-cloud-and-preview-environment-setup)
25
+
-[Setup](#setup)
26
+
-[Enabling Content Sync](#enabling-content-sync)
27
+
-[Installing the @strapi/plugin-gatsby-preview](#installing-the-strapiplugin-gatsby-preview)
28
+
-[Using yarn](#using-yarn-1)
29
+
-[Using npm](#using-npm)
30
+
-[Configurations](#configurations)
21
31
-[Restrictions and limitations](#restrictions-and-limitations)
22
32
23
33
</details>
@@ -42,7 +52,7 @@ You can enable and configure this plugin in your `gatsby-config.js` file.
42
52
43
53
### Basic usage
44
54
45
-
First, you need to configure the `STRAPI_API_URL` and the `STRAPI_TOKEN` environment variables. We recommend using [`dotenv`][https://github.com/motdotla/dotenv] to expose these variables.
55
+
First, you need to configure the `STRAPI_API_URL` and the `STRAPI_TOKEN` environment variables. We recommend using [`dotenv`](https://github.com/motdotla/dotenv) to expose these variables.
46
56
47
57
Make sure to create a full-access [API token](https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/configurations/optional/api-tokens.html) in Strapi.
48
58
@@ -248,7 +258,7 @@ To query a specific component use the following query:
248
258
249
259
#### Dynamic zones
250
260
251
-
To query dynamic zones, , write a query using [inline GraphQL fragments](https://graphql.org/learn/queries/#inline-fragments).
261
+
To query dynamic zones, write a query using [inline GraphQL fragments](https://graphql.org/learn/queries/#inline-fragments).
252
262
253
263
You can use the following query:
254
264
@@ -280,6 +290,62 @@ You can use the following query:
280
290
}
281
291
```
282
292
293
+
#### Internationalization
294
+
295
+
Content types in Strapi can be localized with the [i18n plugin](https://docs.strapi.io/developer-docs/latest/plugins/i18n.html). But by default, gatsby-source-strapi will only fetch data in the default locale of your Strapi app. To specify which locale should be fetched, an `i18n` object can be provided in the content type's `pluginOptions`. You can also set the locale to `all` to get all available localizations of a content type:
296
+
297
+
```javascript
298
+
conststrapiConfig= {
299
+
// ...
300
+
collectionTypes: [
301
+
{
302
+
singularName:'article',
303
+
pluginOptions: {
304
+
i18n: {
305
+
locale:'fr', // Only fetch a specific locale
306
+
},
307
+
},
308
+
},
309
+
],
310
+
singleTypes: [
311
+
{
312
+
singularName:'global',
313
+
pluginOptions: {
314
+
i18n: {
315
+
locale:'all', // Fetch all localizations
316
+
},
317
+
},
318
+
},
319
+
],
320
+
// ...
321
+
};
322
+
```
323
+
324
+
Then use the one of the following queries to fetch a localized content type:
0 commit comments