@sanity/document-internationalization 2.0.0 → 2.0.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/README.md +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.esm.js +6 -9
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +6 -9
- package/lib/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/DocumentInternationalizationMenu.tsx +2 -1
- package/src/plugin.tsx +6 -11
- package/src/types.ts +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/document-internationalization",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Create unique translations of a document based on its language, joined by a shared reference document.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@sanity/ui": "^1.2.2",
|
|
56
56
|
"@sanity/uuid": "^3.0.1",
|
|
57
57
|
"sanity-plugin-internationalized-array": "^1.6.0",
|
|
58
|
-
"sanity-plugin-utils": "^1.6.
|
|
58
|
+
"sanity-plugin-utils": "^1.6.2"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@commitlint/cli": "^17.4.4",
|
|
@@ -24,7 +24,8 @@ import Warning from './Warning'
|
|
|
24
24
|
export function DocumentInternationalizationMenu(
|
|
25
25
|
props: DocumentInternationalizationMenuProps
|
|
26
26
|
) {
|
|
27
|
-
const {
|
|
27
|
+
const {documentId} = props
|
|
28
|
+
const schemaType = props.schemaType.name
|
|
28
29
|
const {languageField, supportedLanguages} =
|
|
29
30
|
useDocumentInternationalizationContext()
|
|
30
31
|
|
package/src/plugin.tsx
CHANGED
|
@@ -25,16 +25,7 @@ export const documentInternationalization = definePlugin<PluginConfig>(
|
|
|
25
25
|
|
|
26
26
|
if (schemaTypes.length === 0) {
|
|
27
27
|
throw new Error(
|
|
28
|
-
'You must specify at least one schema type on which to enable document internationalization. Update the `schemaTypes` option in
|
|
29
|
-
)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const renderLanguageFilter = (schemaType: string, documentId: string) => {
|
|
33
|
-
return (
|
|
34
|
-
<DocumentInternationalizationMenu
|
|
35
|
-
schemaType={schemaType}
|
|
36
|
-
documentId={documentId}
|
|
37
|
-
/>
|
|
28
|
+
'You must specify at least one schema type on which to enable document internationalization. Update the `schemaTypes` option in the documentInternationalization() configuration.'
|
|
38
29
|
)
|
|
39
30
|
}
|
|
40
31
|
|
|
@@ -96,7 +87,11 @@ export const documentInternationalization = definePlugin<PluginConfig>(
|
|
|
96
87
|
const {schemaType, documentId} = ctx
|
|
97
88
|
|
|
98
89
|
return schemaTypes.includes(schemaType) && documentId
|
|
99
|
-
? [
|
|
90
|
+
? [
|
|
91
|
+
...prev,
|
|
92
|
+
(props) =>
|
|
93
|
+
DocumentInternationalizationMenu({...props, documentId}),
|
|
94
|
+
]
|
|
100
95
|
: prev
|
|
101
96
|
},
|
|
102
97
|
badges: (prev, {schemaType}) => {
|
package/src/types.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
FieldDefinition,
|
|
3
3
|
KeyedObject,
|
|
4
|
+
ObjectSchemaType,
|
|
4
5
|
Reference,
|
|
5
6
|
SanityClient,
|
|
6
7
|
} from 'sanity'
|
|
@@ -43,6 +44,6 @@ export type Metadata = {
|
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
export type DocumentInternationalizationMenuProps = {
|
|
46
|
-
schemaType:
|
|
47
|
+
schemaType: ObjectSchemaType
|
|
47
48
|
documentId: string
|
|
48
49
|
}
|