@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/document-internationalization",
3
- "version": "2.0.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.1"
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 {schemaType, documentId} = props
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 te documentInternationalization() configuration.'
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
- ? [...prev, () => renderLanguageFilter(schemaType, documentId)]
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: string
47
+ schemaType: ObjectSchemaType
47
48
  documentId: string
48
49
  }