sanity-io / document-internationalization

Create unique translations of a document based on its language, joined by a shared reference document
MIT License
135 stars 39 forks source link

How is `metadataFields` supposed to work? #170

Open rijk opened 10 months ago

rijk commented 10 months ago

Apologies as this is not a bug, but a question. I've read the docs, the special doc page on this, and looked through the source code, but I cannot figure out how metadataFields is supposed to work.

I've added it to my config:

documentInternationalization({
  supportedLanguages: [
    {id: 'nl', title: 'Nederlands'},
    {id: 'en', title: 'English'},
  ],
  schemaTypes: ['home', 'settings', 'page'],
  metadataFields: [defineField({name: 'slug', type: 'slug'})],
}),

But it doesn't seem to do anything. I still get the Slug is already in use error on page translations:

image

Am I misunderstanding how to use this?

sail-stian commented 5 months ago

Probably a bit late to answer here, but I was also confused by this. When you add the metadataFields option it does not move the field from the document, it simply creates a new field in the language document (go to "manage translations" on the relevant document to see it). I assume what is ment in the documentation is that you can use the slug field in the language document instead of the slug field in the original documents.

I hope this helps someone. I ended up using a custom uniqueness check instead.