@cliff-studio/sanity-plugin-bunny-input 1.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 ADDED
@@ -0,0 +1,130 @@
1
+ # @cliffstudio/sanity-plugin-bunny-input
2
+
3
+ A Sanity Studio plugin for uploading and managing videos via [Bunny Stream](https://bunny.net/stream/).
4
+
5
+ ## Features
6
+
7
+ - Drag & drop video uploads directly in Sanity Studio
8
+ - Upload progress indicator
9
+ - Automatic status polling (uploading → processing → ready)
10
+ - Thumbnail preview when video is ready
11
+ - Video deletion support
12
+
13
+ ## Installation
14
+
15
+ ### From GitHub (private repo)
16
+
17
+ ```bash
18
+ npm install github:cliffstudio/sanity-plugin-bunny-input
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
35
+ ```
36
+
37
+ ## Setup
38
+
39
+ ### 1. Get your Bunny Stream credentials
40
+
41
+ 1. Log in to [bunny.net](https://bunny.net)
42
+ 2. Go to **Stream** → Create or select a **Video Library**
43
+ 3. Find your **Library ID** (numeric ID in the URL or settings)
44
+ 4. Go to **API** section to find your **Stream API Key**
45
+
46
+ ### 2. Add the plugin to your Sanity config
47
+
48
+ ```ts
49
+ // sanity.config.ts
50
+ import {defineConfig} from 'sanity'
51
+ import {bunnyInput} from '@cliffstudio/sanity-plugin-bunny-input'
52
+
53
+ export default defineConfig({
54
+ // ... other config
55
+ plugins: [
56
+ bunnyInput({
57
+ libraryId: process.env.SANITY_STUDIO_BUNNY_LIBRARY_ID,
58
+ // Optional: auto-create/use this Bunny Stream collection (folder) for uploads
59
+ collectionName: process.env.SANITY_STUDIO_BUNNY_COLLECTION_NAME,
60
+ // Optional alternative: hardcode an existing collection GUID
61
+ // collectionId: process.env.SANITY_STUDIO_BUNNY_COLLECTION_ID,
62
+ apiKey: process.env.SANITY_STUDIO_BUNNY_API_KEY,
63
+ }),
64
+ ],
65
+ })
66
+ ```
67
+
68
+ ### 3. Configure environment variables
69
+
70
+ #### For Sanity Studio (`.env`)
71
+
72
+ ```bash
73
+ SANITY_STUDIO_BUNNY_LIBRARY_ID=your-library-id
74
+ SANITY_STUDIO_BUNNY_COLLECTION_NAME=my-project-videos
75
+ # Optional alternative:
76
+ # SANITY_STUDIO_BUNNY_COLLECTION_ID=existing-collection-guid
77
+ SANITY_STUDIO_BUNNY_API_KEY=your-api-key
78
+ ```
79
+
80
+ ### 4. Use in your schemas
81
+
82
+ ```ts
83
+ import {defineField, defineType} from 'sanity'
84
+
85
+ export default defineType({
86
+ name: 'myDocument',
87
+ type: 'document',
88
+ fields: [
89
+ defineField({
90
+ name: 'video',
91
+ title: 'Video',
92
+ type: 'bunnyVideo',
93
+ }),
94
+ ],
95
+ })
96
+ ```
97
+
98
+ ## Collections (folders)
99
+
100
+ You can route uploads into a Bunny Stream collection (folder):
101
+
102
+ - Set `collectionId` to use an existing collection GUID directly.
103
+ - Or set `collectionName` to auto-create/use a collection by name.
104
+ - If you use `collectionName`, the plugin will look up/create that collection before upload.
105
+
106
+ `collectionId` takes precedence if both are provided.
107
+
108
+ ## Schema
109
+
110
+ The `bunnyVideo` type stores:
111
+
112
+ ```ts
113
+ {
114
+ _type: 'bunnyVideo',
115
+ videoId: string, // Bunny's GUID
116
+ libraryId: string, // Your library ID
117
+ collectionId?: string, // Bunny collection GUID (if configured)
118
+ collectionName?: string, // Bunny collection name (if configured)
119
+ title: string, // Video title
120
+ status: 'uploading' | 'processing' | 'ready' | 'error',
121
+ thumbnailUrl: string, // Auto-generated thumbnail
122
+ playbackUrl: string, // HLS playlist URL
123
+ mp4Url: string, // Direct MP4 URL
124
+ duration: number, // Duration in seconds
125
+ }
126
+ ```
127
+
128
+ ## License
129
+
130
+ MIT