sanity-plugin-singleton-management 1.0.6 → 1.0.7
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 +29 -25
- package/package.json +40 -27
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# sanity-plugin-singleton-tools
|
|
4
4
|
|
|
5
|
-
> This is compatible with
|
|
5
|
+
> This is compatible with Sanity versions 3.x, 4.x, and 5.x.
|
|
6
6
|
|
|
7
7
|
## What does this plugin do?
|
|
8
8
|
|
|
@@ -20,23 +20,23 @@ While Sanity Studio supports singleton documents through the Structure Builder A
|
|
|
20
20
|
plugin eliminates the repetitive boilerplate and provides additional safeguards:
|
|
21
21
|
|
|
22
22
|
### Native Sanity Approach
|
|
23
|
+
|
|
23
24
|
```js
|
|
24
25
|
// Requires manual Structure Builder configuration for each singleton
|
|
25
26
|
export const structure = (S) =>
|
|
26
27
|
S.list()
|
|
27
|
-
.title(
|
|
28
|
+
.title("Content")
|
|
28
29
|
.items([
|
|
29
30
|
S.listItem()
|
|
30
|
-
.title(
|
|
31
|
+
.title("Site Settings")
|
|
31
32
|
.child(
|
|
32
|
-
S.document()
|
|
33
|
-
.schemaType('siteSettings')
|
|
34
|
-
.documentId('siteSettings')
|
|
33
|
+
S.document().schemaType("siteSettings").documentId("siteSettings"),
|
|
35
34
|
),
|
|
36
35
|
// Must manually filter out singletons from main list
|
|
37
|
-
...S.documentTypeListItems().filter(
|
|
38
|
-
![
|
|
39
|
-
|
|
36
|
+
...S.documentTypeListItems().filter(
|
|
37
|
+
(listItem) => !["siteSettings"].includes(listItem.getId()),
|
|
38
|
+
),
|
|
39
|
+
]);
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
**Issues:**
|
|
@@ -46,7 +46,6 @@ export const structure = (S) =>
|
|
|
46
46
|
- Users can still create new versions via global Create menu
|
|
47
47
|
- Manual filtering required to prevent duplicates in document lists
|
|
48
48
|
|
|
49
|
-
|
|
50
49
|
**With This Plugin:**
|
|
51
50
|
|
|
52
51
|
```js
|
|
@@ -72,21 +71,21 @@ export const mySingleton = defineType({
|
|
|
72
71
|
```
|
|
73
72
|
|
|
74
73
|
```js
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
])
|
|
74
|
+
// structure.js/ts
|
|
75
|
+
export const structure = (S, context) =>
|
|
76
|
+
S.list().items([
|
|
77
|
+
...singletonDocumentListItems({ S, context }), // Auto-generates all singletons
|
|
78
|
+
...filteredDocumentListItems({ S, context }), // Auto-filters singletons from main list
|
|
79
|
+
]);
|
|
82
80
|
```
|
|
83
81
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
82
|
+
Benefits:
|
|
83
|
+
|
|
84
|
+
- ✅ Minimal configuration with `singleton: true`
|
|
85
|
+
- ✅ Automatic action restrictions (no duplicate creation)
|
|
86
|
+
- ✅ Global Create menu integration
|
|
87
|
+
- ✅ Helper functions eliminate boilerplate
|
|
88
|
+
- ✅ Consistent singleton behavior across your studio
|
|
90
89
|
|
|
91
90
|
## Installation
|
|
92
91
|
|
|
@@ -99,17 +98,21 @@ npm install sanity-plugin-singleton-management
|
|
|
99
98
|
This plugin is a modernized, actively maintained fork of `sanity-plugin-singleton-tools` with identical API compatibility. Migration is straightforward:
|
|
100
99
|
|
|
101
100
|
### Steps
|
|
101
|
+
|
|
102
102
|
1. **Uninstall the old package**:
|
|
103
|
+
|
|
103
104
|
```sh
|
|
104
105
|
npm uninstall sanity-plugin-singleton-tools
|
|
105
106
|
```
|
|
106
107
|
|
|
107
108
|
2. **Install this package**:
|
|
109
|
+
|
|
108
110
|
```sh
|
|
109
111
|
npm install sanity-plugin-singleton-management
|
|
110
112
|
```
|
|
111
113
|
|
|
112
114
|
3. **Update your import statements**:
|
|
115
|
+
|
|
113
116
|
```diff
|
|
114
117
|
// sanity.config.js
|
|
115
118
|
- import { singletonTools } from 'sanity-plugin-singleton-tools'
|
|
@@ -123,6 +126,7 @@ This plugin is a modernized, actively maintained fork of `sanity-plugin-singleto
|
|
|
123
126
|
**That's it!** No other code changes are required. Your existing schema configurations and structure customizations will work exactly the same.
|
|
124
127
|
|
|
125
128
|
### What's New
|
|
129
|
+
|
|
126
130
|
- ✅ **React 18/19 Support**: Compatible with modern React versions
|
|
127
131
|
- ✅ **Sanity v3/v4 Support**: Works with both Sanity Studio versions
|
|
128
132
|
- ✅ **Modern Tooling**: ESM/CommonJS dual package, better TypeScript support
|
|
@@ -205,7 +209,7 @@ Other reading (Sanity docs):
|
|
|
205
209
|
|
|
206
210
|
## Credits
|
|
207
211
|
|
|
208
|
-
This project is a fork of [sanity-plugin-singleton-tools](https://github.com/plsrd/sanity-plugin-singleton-tools)
|
|
212
|
+
This project is a fork of [sanity-plugin-singleton-tools](https://github.com/plsrd/sanity-plugin-singleton-tools)
|
|
209
213
|
originally created by [RD Pennell](https://github.com/plsrd).
|
|
210
214
|
|
|
211
215
|
## License
|
|
@@ -216,4 +220,4 @@ MIT License \
|
|
|
216
220
|
<div style="text-align: right">
|
|
217
221
|
Copyright © 2025 <a href="https://github.com/rcmaples" target="_blank">RC Maples</a> </br>
|
|
218
222
|
Copyright © 2024-2025 <a href="https://github.com/plsrd" target="_blank">RD Pennell</a>
|
|
219
|
-
</div>
|
|
223
|
+
</div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sanity-plugin-singleton-management",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "A plugin to streamline singleton management in your Sanity Studio",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -53,57 +53,70 @@
|
|
|
53
53
|
"@sanity/incompatible-plugin": "^1.0.5"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@
|
|
56
|
+
"@emnapi/core": "^1.9.2",
|
|
57
|
+
"@emnapi/runtime": "^1.9.2",
|
|
58
|
+
"@commitlint/cli": "^20.4.0",
|
|
57
59
|
"@commitlint/config-conventional": "^20.0.0",
|
|
58
|
-
"@commitlint/prompt-cli": "^20.1
|
|
60
|
+
"@commitlint/prompt-cli": "^20.3.1",
|
|
61
|
+
"@eslint-react/eslint-plugin": "^4.2.3",
|
|
62
|
+
"@eslint/js": "^10.0.1",
|
|
59
63
|
"@sanity/browserslist-config": "^1.0.5",
|
|
60
|
-
"@sanity/pkg-utils": "^10.
|
|
64
|
+
"@sanity/pkg-utils": "^10.4.1",
|
|
61
65
|
"@sanity/plugin-kit": "^4.0.20",
|
|
62
66
|
"@semantic-release/changelog": "^6.0.3",
|
|
63
67
|
"@semantic-release/git": "^10.0.1",
|
|
64
|
-
"@semantic-release/github": "^
|
|
65
|
-
"@semantic-release/npm": "^13.1.
|
|
68
|
+
"@semantic-release/github": "^12.0.6",
|
|
69
|
+
"@semantic-release/npm": "^13.1.5",
|
|
66
70
|
"@testing-library/jest-dom": "^6.4.6",
|
|
67
|
-
"@types/react": "^19.2.
|
|
68
|
-
"@
|
|
69
|
-
"@
|
|
70
|
-
"
|
|
71
|
-
"@vitest/ui": "^4.0.1",
|
|
72
|
-
"eslint": "^9.35.0",
|
|
71
|
+
"@types/react": "^19.2.9",
|
|
72
|
+
"@vitest/coverage-v8": "^4.1.2",
|
|
73
|
+
"@vitest/ui": "^4.1.2",
|
|
74
|
+
"eslint": "^10.2.0",
|
|
73
75
|
"eslint-config-prettier": "^10.1.8",
|
|
74
|
-
"eslint-
|
|
75
|
-
"eslint-plugin-prettier": "^5.1.3",
|
|
76
|
-
"eslint-plugin-react": "^7.34.0",
|
|
77
|
-
"eslint-plugin-react-hooks": "^7.0.0",
|
|
76
|
+
"eslint-plugin-react-hooks": "7.1.0-canary-ed69815c-20260323",
|
|
78
77
|
"husky": "^9.1.7",
|
|
79
|
-
"jsdom": "^27.0.0",
|
|
80
78
|
"npm-run-all": "^4.1.5",
|
|
81
79
|
"prettier": "^3.2.5",
|
|
82
|
-
"prettier-plugin-packagejson": "^
|
|
80
|
+
"prettier-plugin-packagejson": "^3.0.0",
|
|
83
81
|
"react": "^19.2.3",
|
|
84
|
-
"react-dom": "^19.2.
|
|
82
|
+
"react-dom": "^19.2.4",
|
|
85
83
|
"react-is": "^19.2.3",
|
|
86
84
|
"rimraf": "^6.0.1",
|
|
87
|
-
"sanity": "^5.
|
|
88
|
-
"semantic-release": "^25.0.
|
|
89
|
-
"styled-components": "^6.
|
|
90
|
-
"typescript": "^
|
|
91
|
-
"typescript-eslint": "^8.
|
|
92
|
-
"vitest": "^4.
|
|
85
|
+
"sanity": "^5.19.0",
|
|
86
|
+
"semantic-release": "^25.0.3",
|
|
87
|
+
"styled-components": "^6.3.8",
|
|
88
|
+
"typescript": "^6.0.2",
|
|
89
|
+
"typescript-eslint": "^8.58.0",
|
|
90
|
+
"vitest": "^4.1.2"
|
|
93
91
|
},
|
|
94
92
|
"overrides": {
|
|
95
93
|
"esbuild": "0.25.0",
|
|
96
94
|
"prismjs": "1.30.0",
|
|
97
95
|
"tmp": "0.2.4",
|
|
98
96
|
"min-document": "2.19.0",
|
|
99
|
-
"
|
|
97
|
+
"minimatch": "^10.2.1",
|
|
98
|
+
"serialize-javascript": "^7.0.3",
|
|
99
|
+
"glob": "^10.5.0",
|
|
100
|
+
"flatted": "^3.4.2",
|
|
101
|
+
"js-yaml": "^3.14.2",
|
|
102
|
+
"ajv": "^8.18.0",
|
|
103
|
+
"lodash": "^4.18.0",
|
|
104
|
+
"brace-expansion": "^5.0.5",
|
|
105
|
+
"picomatch": "^4.0.4",
|
|
106
|
+
"typescript": "^6.0.2",
|
|
107
|
+
"eslint": {
|
|
108
|
+
"ajv": "^6.14.0"
|
|
109
|
+
},
|
|
110
|
+
"@sanity/pkg-utils": {
|
|
111
|
+
"typescript": "^6.0.2"
|
|
112
|
+
}
|
|
100
113
|
},
|
|
101
114
|
"peerDependencies": {
|
|
102
115
|
"react": "^18 || ^19.2.1",
|
|
103
116
|
"sanity": "^3 || ^4 || ^5.0.0-0"
|
|
104
117
|
},
|
|
105
118
|
"engines": {
|
|
106
|
-
"node": ">=20"
|
|
119
|
+
"node": ">=20.19.0"
|
|
107
120
|
},
|
|
108
121
|
"repository": {
|
|
109
122
|
"type": "git",
|