sanity-plugin-internationalized-array 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -14
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -15,26 +15,26 @@ sanity install internationalized-array
|
|
|
15
15
|
Add an array to your schema by importing the helper function.
|
|
16
16
|
|
|
17
17
|
```js
|
|
18
|
-
import {internationalizedArray} from
|
|
18
|
+
import { internationalizedArray } from "sanity-plugin-internationalized-array";
|
|
19
19
|
|
|
20
20
|
// ./src/schema/person.js
|
|
21
21
|
export default {
|
|
22
|
-
name:
|
|
23
|
-
title:
|
|
24
|
-
type:
|
|
22
|
+
name: "person",
|
|
23
|
+
title: "Person",
|
|
24
|
+
type: "document",
|
|
25
25
|
fields: [
|
|
26
26
|
// ...all your other fields
|
|
27
27
|
internationalizedArray({
|
|
28
|
-
name:
|
|
29
|
-
type:
|
|
28
|
+
name: "greeting", // required
|
|
29
|
+
type: "string", // required: string | text | number | boolean
|
|
30
30
|
languages: [
|
|
31
|
-
{id:
|
|
32
|
-
{id:
|
|
33
|
-
] // required, must be an array of objects
|
|
34
|
-
showNativeInput: false // optional: just for debugging
|
|
35
|
-
})
|
|
36
|
-
]
|
|
37
|
-
}
|
|
31
|
+
{ id: "en", title: "English" },
|
|
32
|
+
{ id: "fr", title: "French" },
|
|
33
|
+
], // required, must be an array of objects
|
|
34
|
+
showNativeInput: false, // optional: just for debugging
|
|
35
|
+
}),
|
|
36
|
+
],
|
|
37
|
+
};
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
This will create an Array field where `string` fields can be added with the name `title`. The custom input contains buttons which will add new array items with the language as the `_key` value. Data returned from this array will look like this:
|
|
@@ -56,7 +56,7 @@ Using GROQ filters you can query for a specific language key like so:
|
|
|
56
56
|
|
|
57
57
|
### Why store localised field data like this?
|
|
58
58
|
|
|
59
|
-
The most popular way to store translated content is in an object using the method prescribed in [@sanity/language-filter](https://www.npmjs.com/package/@sanity/language-filter). This works well and creates tidy object structures, but also create a unique field path for every unique field name, multiplied by the number of languages in your dataset.
|
|
59
|
+
The most popular way to store field-level translated content is in an object using the method prescribed in [@sanity/language-filter](https://www.npmjs.com/package/@sanity/language-filter). This works well and creates tidy object structures, but also create a unique field path for every unique field name, multiplied by the number of languages in your dataset.
|
|
60
60
|
|
|
61
61
|
For most people, this won't become an issue. On a very large dataset with a lot of languages, the [Attribute Limit](https://www.sanity.io/docs/attribute-limit) can become a concern.
|
|
62
62
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sanity-plugin-internationalized-array",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "Store localised fields in an array to save on attributes",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -31,14 +31,14 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@nrk/sanity-plugin-nrkno-odd-utils": "^1.0.11",
|
|
33
33
|
"@sanity/icons": "^1.3.1",
|
|
34
|
-
"@sanity/ui": "^0.37.
|
|
34
|
+
"@sanity/ui": "^0.37.9"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@sanity/base": "^2.30.1",
|
|
38
38
|
"@sanity/desk-tool": "^2.30.1",
|
|
39
39
|
"@sanity/form-builder": "^2.30.1",
|
|
40
40
|
"@sanity/util": "^2.29.5",
|
|
41
|
-
"react": "^16.0.0 || ^17.0.0"
|
|
41
|
+
"react": "^16.0.0 || ^17.0.0 || ^18.0.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@sanity/eslint-config-studio": "^2.0.0",
|