@cliff-studio/sanity-plugin-bunny-input 1.2.0 → 2.0.0
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 +42 -43
- package/dist/_chunks-es/index.js +7732 -8823
- package/dist/_chunks-es/index.js.map +1 -1
- package/dist/_chunks-es/refractor.js +4499 -4655
- package/dist/_chunks-es/refractor.js.map +1 -1
- package/package.json +3 -3
- package/src/components/BunnyBrowserModal.jsx +1 -1
- package/src/components/BunnyInput.jsx +3 -1
package/README.md
CHANGED
|
@@ -1,37 +1,21 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @cliff-studio/sanity-plugin-bunny-input
|
|
2
2
|
|
|
3
3
|
A Sanity Studio plugin for uploading and managing videos via [Bunny Stream](https://bunny.net/stream/).
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
-
|
|
7
|
+
- Upload videos directly from Sanity Studio
|
|
8
|
+
- Browse and select existing videos from your Bunny collection
|
|
8
9
|
- Upload progress indicator
|
|
9
10
|
- Automatic status polling (uploading → processing → ready)
|
|
10
11
|
- Thumbnail preview when video is ready
|
|
11
|
-
-
|
|
12
|
+
- Stores video metadata (dimensions, duration, orientation, URLs)
|
|
13
|
+
- Proxy endpoint support to keep your API key server-side
|
|
12
14
|
|
|
13
15
|
## Installation
|
|
14
16
|
|
|
15
|
-
### From GitHub (private repo)
|
|
16
|
-
|
|
17
17
|
```bash
|
|
18
|
-
npm install
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
Or add to your `package.json`:
|
|
22
|
-
|
|
23
|
-
```json
|
|
24
|
-
{
|
|
25
|
-
"dependencies": {
|
|
26
|
-
"@cliffstudio/sanity-plugin-bunny-input": "github:cliffstudio/sanity-plugin-bunny-input"
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
### From npm (if published)
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
npm install @cliffstudio/sanity-plugin-bunny-input
|
|
18
|
+
npm install @cliff-studio/sanity-plugin-bunny-input
|
|
35
19
|
```
|
|
36
20
|
|
|
37
21
|
## Setup
|
|
@@ -41,25 +25,27 @@ npm install @cliffstudio/sanity-plugin-bunny-input
|
|
|
41
25
|
1. Log in to [bunny.net](https://bunny.net)
|
|
42
26
|
2. Go to **Stream** → Create or select a **Video Library**
|
|
43
27
|
3. Find your **Library ID** (numeric ID in the URL or settings)
|
|
44
|
-
4.
|
|
28
|
+
4. Find your **CDN Hostname** in the library settings (e.g. `vz-abc123-xyz.b-cdn.net`)
|
|
29
|
+
5. Go to the **API** section to find your **Stream API Key**
|
|
45
30
|
|
|
46
31
|
### 2. Add the plugin to your Sanity config
|
|
47
32
|
|
|
48
33
|
```ts
|
|
49
34
|
// sanity.config.ts
|
|
50
35
|
import {defineConfig} from 'sanity'
|
|
51
|
-
import {bunnyInput} from '@
|
|
36
|
+
import {bunnyInput} from '@cliff-studio/sanity-plugin-bunny-input'
|
|
52
37
|
|
|
53
38
|
export default defineConfig({
|
|
54
39
|
// ... other config
|
|
55
40
|
plugins: [
|
|
56
41
|
bunnyInput({
|
|
57
42
|
libraryId: process.env.SANITY_STUDIO_BUNNY_LIBRARY_ID,
|
|
58
|
-
|
|
43
|
+
cdnHostname: process.env.SANITY_STUDIO_BUNNY_CDN_HOSTNAME,
|
|
44
|
+
apiKey: process.env.SANITY_STUDIO_BUNNY_API_KEY,
|
|
45
|
+
// Optional: scope uploads and browsing to a specific collection
|
|
59
46
|
collectionName: process.env.SANITY_STUDIO_BUNNY_COLLECTION_NAME,
|
|
60
|
-
// Optional alternative:
|
|
47
|
+
// Optional alternative: use an existing collection GUID directly
|
|
61
48
|
// collectionId: process.env.SANITY_STUDIO_BUNNY_COLLECTION_ID,
|
|
62
|
-
apiKey: process.env.SANITY_STUDIO_BUNNY_API_KEY,
|
|
63
49
|
}),
|
|
64
50
|
],
|
|
65
51
|
})
|
|
@@ -67,14 +53,12 @@ export default defineConfig({
|
|
|
67
53
|
|
|
68
54
|
### 3. Configure environment variables
|
|
69
55
|
|
|
70
|
-
#### For Sanity Studio (`.env`)
|
|
71
|
-
|
|
72
56
|
```bash
|
|
73
57
|
SANITY_STUDIO_BUNNY_LIBRARY_ID=your-library-id
|
|
74
|
-
|
|
75
|
-
# Optional alternative:
|
|
76
|
-
# SANITY_STUDIO_BUNNY_COLLECTION_ID=existing-collection-guid
|
|
58
|
+
SANITY_STUDIO_BUNNY_CDN_HOSTNAME=vz-abc123-xyz.b-cdn.net
|
|
77
59
|
SANITY_STUDIO_BUNNY_API_KEY=your-api-key
|
|
60
|
+
# Optional:
|
|
61
|
+
SANITY_STUDIO_BUNNY_COLLECTION_NAME=my-project-videos
|
|
78
62
|
```
|
|
79
63
|
|
|
80
64
|
### 4. Use in your schemas
|
|
@@ -97,14 +81,25 @@ export default defineType({
|
|
|
97
81
|
|
|
98
82
|
## Collections (folders)
|
|
99
83
|
|
|
100
|
-
You can
|
|
84
|
+
You can scope uploads and library browsing to a Bunny Stream collection (folder):
|
|
101
85
|
|
|
102
|
-
- Set `
|
|
103
|
-
- Or set `
|
|
104
|
-
- If you use `collectionName`, the plugin will look up/create that collection before upload.
|
|
86
|
+
- Set `collectionName` to auto-create/use a collection by name.
|
|
87
|
+
- Or set `collectionId` to use an existing collection GUID directly.
|
|
105
88
|
|
|
106
89
|
`collectionId` takes precedence if both are provided.
|
|
107
90
|
|
|
91
|
+
## Security
|
|
92
|
+
|
|
93
|
+
Passing `apiKey` directly exposes your Bunny API key in the browser. For production use, set up a `proxyEndpoint` instead — a small server-side proxy that adds the API key before forwarding requests to Bunny. Pass `proxyEndpoint` in place of `apiKey`:
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
bunnyInput({
|
|
97
|
+
libraryId: process.env.SANITY_STUDIO_BUNNY_LIBRARY_ID,
|
|
98
|
+
cdnHostname: process.env.SANITY_STUDIO_BUNNY_CDN_HOSTNAME,
|
|
99
|
+
proxyEndpoint: process.env.SANITY_STUDIO_BUNNY_PROXY_URL,
|
|
100
|
+
})
|
|
101
|
+
```
|
|
102
|
+
|
|
108
103
|
## Schema
|
|
109
104
|
|
|
110
105
|
The `bunnyVideo` type stores:
|
|
@@ -112,16 +107,20 @@ The `bunnyVideo` type stores:
|
|
|
112
107
|
```ts
|
|
113
108
|
{
|
|
114
109
|
_type: 'bunnyVideo',
|
|
115
|
-
videoId: string,
|
|
116
|
-
libraryId: string,
|
|
110
|
+
videoId: string, // Bunny's GUID
|
|
111
|
+
libraryId: string, // Your library ID
|
|
117
112
|
collectionId?: string, // Bunny collection GUID (if configured)
|
|
118
113
|
collectionName?: string, // Bunny collection name (if configured)
|
|
119
|
-
title: string,
|
|
114
|
+
title: string, // Video title
|
|
120
115
|
status: 'uploading' | 'processing' | 'ready' | 'error',
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
116
|
+
width: number, // Video width in pixels
|
|
117
|
+
height: number, // Video height in pixels
|
|
118
|
+
ratio: number, // width / height
|
|
119
|
+
orientation: 'landscape' | 'portrait' | 'square',
|
|
120
|
+
duration: number, // Duration in seconds
|
|
121
|
+
thumbnailUrl: string, // Auto-generated thumbnail
|
|
122
|
+
playbackUrl: string, // HLS playlist URL
|
|
123
|
+
mp4Url: string, // Direct MP4 URL (highest available resolution)
|
|
125
124
|
}
|
|
126
125
|
```
|
|
127
126
|
|