sanity-plugin-internationalized-array 1.6.0 → 1.6.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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 Simeon Griggs
3
+ Copyright (c) 2023 Sanity.io
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  > This is the **Sanity Studio v3 version** of sanity-plugin-internationalized-array.
2
2
  >
3
- > For the v2 version, please refer to the [v2-branch](https://github.com/SimeonGriggs/sanity-plugin-internationalized-array/tree/studio-v2).
3
+ > For the v2 version, please refer to the [v2-branch](https://github.com/sanity-io/sanity-plugin-internationalized-array/tree/studio-v2).
4
4
 
5
5
  # sanity-plugin-internationalized-array
6
6
 
7
7
  A helper function that renders a custom input component for writing localized fields of content into an array.
8
8
 
9
- ![Screenshot of an internationalized input](./img/screenshot.png)
9
+ ![Screenshot of an internationalized input](./img/internationalized-array.png)
10
10
 
11
11
  ## Installation
12
12
 
@@ -76,6 +76,32 @@ languages: async () => {
76
76
  }
77
77
  ```
78
78
 
79
+ The async function contains a configured Sanity Client in the first parameter, allowing you to store Language options as documents. Your query should return an array of objects with an `id` and `title`.
80
+
81
+ ```ts
82
+ languages: async (client) => {
83
+ const response = await client.fetch(`*[_type == "language"]{ id, title }`)
84
+ return response
85
+ },
86
+ ```
87
+
88
+ Additionally, you can "pick" fields from a document, to pass into the query. For example, if you have a concept of "Markets" where only certain language fields are required in certain markets.
89
+
90
+ In this example, each language document has an array of strings called `markets` to declare where that language can be used. And the document being authored has a single `market` field.
91
+
92
+ ```ts
93
+ select: {
94
+ market: 'market'
95
+ },
96
+ languages: async (client, {market = ``}) => {
97
+ const response = await client.fetch(
98
+ `*[_type == "language" && $market in markets]{ id, title }`,
99
+ {market}
100
+ )
101
+ return response
102
+ },
103
+ ```
104
+
79
105
  ## Using more complex field types
80
106
 
81
107
  For more control over the `value` field, you can pass a schema definition into the `fieldTypes` array.
@@ -135,7 +161,7 @@ Using GROQ filters you can query for a specific language key like so:
135
161
 
136
162
  ## Migrate from objects to arrays
137
163
 
138
- [See the migration script](https://github.com/SimeonGriggs/sanity-plugin-internationalized-array/blob/main/migrations/transformObjectToArray.js) inside `./migrations/transformObjectToArray.js` of this Repo.
164
+ [See the migration script](https://github.com/sanity-io/sanity-plugin-internationalized-array/blob/main/migrations/transformObjectToArray.js) inside `./migrations/transformObjectToArray.js` of this Repo.
139
165
 
140
166
  Follow the instructions inside the script and set the `_type` and field name you wish to target.
141
167
 
@@ -196,7 +222,7 @@ on how to run this plugin with hotreload in the studio.
196
222
 
197
223
  ### Release new version
198
224
 
199
- Run ["CI & Release" workflow](https://github.com/SimeonGriggs/sanity-plugin-internationalized-array/actions/workflows/main.yml).
225
+ Run ["CI & Release" workflow](https://github.com/sanity-io/sanity-plugin-internationalized-array/actions/workflows/main.yml).
200
226
  Make sure to select the main branch and check "Release new version".
201
227
 
202
228
  Semantic release will only release on configured branches, so it is safe to run release on any branch.
@@ -5,7 +5,12 @@ import type {Rule} from 'sanity'
5
5
  import type {RuleTypeConstraint} from 'sanity'
6
6
  import type {SanityClient} from 'sanity'
7
7
 
8
- export declare type AllowedType = 'string' | 'number' | 'boolean' | 'text' | 'reference'
8
+ export declare type AllowedType =
9
+ | 'string'
10
+ | 'number'
11
+ | 'boolean'
12
+ | 'text'
13
+ | 'reference'
9
14
 
10
15
  export declare type ArrayConfig = {
11
16
  name: string