sanity-plugin-internationalized-array 1.6.0 → 1.6.1

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
@@ -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.
@@ -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