Gathering detailed insights and metrics for sanity-plugin-sync-content
Gathering detailed insights and metrics for sanity-plugin-sync-content
Gathering detailed insights and metrics for sanity-plugin-sync-content
Gathering detailed insights and metrics for sanity-plugin-sync-content
A Sanity plugin for copy and pasting referenced blocks in array type of fields in Sanity Studio. Based on sanity-plugin-copy-paste, but was configured to fit the use cases of our projects needs.
npm install sanity-plugin-sync-content
Typescript
Module System
Min. Node Version
Node Version
NPM Version
TypeScript (88.98%)
JavaScript (11.02%)
Total Downloads
825
Last Day
4
Last Week
8
Last Month
21
Last Year
468
MIT License
4 Stars
35 Commits
5 Branches
6 Contributors
Updated on Dec 11, 2024
Minified
Minified + Gzipped
Latest Version
1.2.0
Package Id
sanity-plugin-sync-content@1.2.0
Unpacked Size
126.50 kB
Size
31.62 kB
File Count
32
NPM Version
10.8.3
Node Version
20.17.0
Published on
Sep 06, 2024
Cumulative downloads
Total Downloads
32
A Sanity plugin for copy and pasting referenced blocks in array type of fields in Sanity Studio. Based on sanity-plugin-copy-paste, but was configured to fit the use cases of our projects needs.
This is a Sanity Studio v3 plugin.
1npm install sanity-plugin-sync-content
Add it as a plugin in sanity.config.ts
(or .js):
1import { defineConfig } from 'sanity'; 2import { syncContentPlugin } from 'sanity-plugin-sync-content'; 3 4export default defineConfig({ 5 //... 6 plugins: [ 7 // ...other plugins 8 syncContentPlugin(), 9 ], 10});
Just add directly the defineField for copyPaste directly into any of your referenced block array like so:
1import { defineConfig } from 'sanity'; 2import { copyPaste } from 'sanity-plugin-sync-content'; 3 4export default defineType({ 5 name: 'my-section', 6 title: 'My Example Section', 7 type: 'object', 8 fields: [ 9 copyPaste, 10 // ...your-other-fields 11 ], 12});
You can override some of the configuration for the copyPaste field like so:
1export default defineType({ 2 name: 'my-section', 3 title: 'My Example Section', 4 type: 'object', 5 fields: [ 6 { 7 ...copyPaste, 8 title: 'The New Copy Paste Title', 9 hidden: () => { 10 // Some logic 11 12 return true; 13 }, 14 // ...other configurations 15 }, 16 // ...your-other-fields 17 ], 18});
This plugin uses the Studio UI Localization resource bundle, it is now possible to localize the fields to fit your needs.
Here is the default English bundle:
1{ 2 // Title of the schema field 3 'schema.title': 'Copy/paste the item', 4 5 // Toast 6 'toast.success.copy.title': 'Copied successfully', 7 'toast.success.paste.title': 'Pasted successfully', 8 'toast.success.duplicate.title': 9 'Duplicated to {{pageCount}} pages successfully', 10 'toast.warning.duplicate.title': 11 'Duplicated to {{pageCount}} pages with some warnings', 12 'toast.error.title': 'Something went wrong', 13 14 // Dialog 15 'dialog.header.title': 'Duplicate to multiple pages', 16 'dialog.checkbox.form.title': 'Ordered by update date', 17 'dialog.deselect.title': 'Deselect all', 18 'dialog.pasting.title': 'Duplicating to selected pages...', 19 'dialog.paste.title': 'Duplicate the block to selected pages', 20 'dialog.loading.title': 'Loading some content…', 21 22 // Buttons 23 'button.duplicate.title': 'Duplicate to multiple pages', 24 'button.copy.title': 'Copy', 25 'button.paste.title': 'Paste', 26 'button.pasting.title': 'Pasting...', 27}
en-US
de-DE
If you want to override or add a new language, you will need to create a custom bundle with your desired translations. In order to override/add you must use sanity-plugin-sync-content
as the namespace and add it to the i18n
object in your sanity plugin configuration. Here is an example:
1const myEnglishOverride = defineLocaleResourceBundle({
2 // make sure the `locale` language code corresponds to the one you want to override
3 locale: 'en-US',
4 namespace: 'sanity-plugin-sync-content',
5 resources: {
6 'button.copy.title': 'My custom Copy title',
7 },
8});
9
10// sanity.config.ts
11export default defineConfig({
12 // ...
13 i18n: {
14 bundles: [myEnglishOverride],
15 },
16});
MIT © Evelan
This plugin uses @sanity/plugin-kit with default configuration for build & watch scripts.
See Testing a plugin in Sanity Studio on how to run this plugin with hotreload in the studio.
Run "CI & Release" workflow. Make sure to select the main branch and check "Release new version".
Semantic release will only release on configured branches, so it is safe to run release on any branch.
No vulnerabilities found.
No security vulnerabilities found.
Last Day
0%
4
Compared to previous day
Last Week
100%
8
Compared to previous week
Last Month
-8.7%
21
Compared to previous month
Last Year
31.1%
468
Compared to previous year