feat(i18n-doc): add support for disabling automatic template creation via addTemplates #780
Conversation
|
@Jamiewarb is attempting to deploy a commit to the Sanity Sandbox Team on Vercel. A member of the Team first needs to authorize it. |
🦋 Changeset detectedLatest commit: 40ede22 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Adds a new plugin configuration option to disable automatic initial value template creation in @sanity/document-internationalization, preserving current behavior by default.
Changes:
- Introduces
addTemplates?: booleanon the plugin config surface. - Gates schema template generation behind the
addTemplatesoption. - Sets
addTemplates: truein the plugin default config and adds a changeset for a minor release.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| plugins/@sanity/document-internationalization/src/types.ts | Adds the addTemplates config option to the public PluginConfig type. |
| plugins/@sanity/document-internationalization/src/plugin.tsx | Skips adding templates when addTemplates is disabled. |
| plugins/@sanity/document-internationalization/src/constants.ts | Defaults addTemplates to true for backward compatibility. |
| .changeset/odd-mangos-knock.md | Declares a minor version bump and documents the new option. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
pedrobonamin
left a comment
There was a problem hiding this comment.
Thank you for this @Jamiewarb !
The change looks good to me, merging it now and doing a release.
Description
This PR adds support for disabling automatic template creation via the
addTemplatesconfig optionThis allows future-proofed disabling of the templates when a user manages them within their own codebase, without needing to looking up template IDs to un-register them, and without needing to check if they've changed each time they update the plugin
By default
addTemplatesistrueto maintain backwards compatibilityWhat to review
Add
addTemplates: falseto the i18n-doc plugin config in the test studio.You'll then be able to see your templates are no longer being added, e.g. via the New Document global menu
Testing
There aren't tests for what what the plugin config outputs currently. However I conducted manual testing to ensure the templates weren't created when
addTemplateswas false