diff --git a/package-lock.json b/package-lock.json index 46db528..27ee5fc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,6 +33,7 @@ "rxjs": "7.8.1", "sanity": "3.58.0", "sanity-plugin-asset-source-unsplash": "3.0.1", + "sanity-plugin-cloudinary": "^1.1.3", "server-only": "0.0.1", "styled-components": "6.1.13" }, @@ -3983,6 +3984,102 @@ "object-inspect": "^1.13.1" } }, + "node_modules/@sanity/studio-secrets": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@sanity/studio-secrets/-/studio-secrets-2.0.2.tgz", + "integrity": "sha512-XVA+08yGwgT4AB87KK6FpNMPfmbvW4VGJywGLQGwvG1WoxjZxnqoy3bKalGNqnMg1CuCKsVoLMtepcr8ylQ6HA==", + "license": "MIT", + "dependencies": { + "@sanity/incompatible-plugin": "^1.0.4", + "@sanity/ui": "^1.0.0" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "react": "^18", + "sanity": "^3.0.0", + "styled-components": "^5.3.0" + } + }, + "node_modules/@sanity/studio-secrets/node_modules/@floating-ui/react-dom": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@floating-ui/react-dom/-/react-dom-2.0.0.tgz", + "integrity": "sha512-Ke0oU3SeuABC2C4OFu2mSAwHIP5WUiV98O9YWoHV4Q5aT6E9k06DV0Khi5uYspR8xmmBk08t8ZDcz3TR3ARkEg==", + "license": "MIT", + "dependencies": { + "@floating-ui/dom": "^1.2.7" + }, + "peerDependencies": { + "react": ">=16.8.0", + "react-dom": ">=16.8.0" + } + }, + "node_modules/@sanity/studio-secrets/node_modules/@sanity/color": { + "version": "2.2.5", + "resolved": "https://registry.npmjs.org/@sanity/color/-/color-2.2.5.tgz", + "integrity": "sha512-tTi22KoKuER3sldXYl4c1Dq2zU7tMLDkljFiaUKVkBbu4PBvRGCFw75kXZnD2b4Bsp6vin+7sI+AKdCKRhfRuw==", + "license": "MIT" + }, + "node_modules/@sanity/studio-secrets/node_modules/@sanity/icons": { + "version": "2.11.8", + "resolved": "https://registry.npmjs.org/@sanity/icons/-/icons-2.11.8.tgz", + "integrity": "sha512-C4ViXtk6eyiNTQ5OmxpfmcK6Jw+LLTi9zg9XBUD15DzC4xTHaGW9SVfUa43YtPGs3WC3M0t0K59r0GDjh52HIg==", + "license": "MIT", + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "react": "^18" + } + }, + "node_modules/@sanity/studio-secrets/node_modules/@sanity/ui": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/@sanity/ui/-/ui-1.9.3.tgz", + "integrity": "sha512-AdWEVFaK0Snk6xxP0lGPVP3QQYKwzkfGFpFZnL9d6UtWt8yeuS8BMLVAzmXzg14hrqH50ex9nvNl3eq6a0MWiw==", + "license": "MIT", + "dependencies": { + "@floating-ui/react-dom": "2.0.0", + "@sanity/color": "^2.2.5", + "@sanity/icons": "^2.4.1", + "csstype": "^3.1.2", + "framer-motion": "^10.16.2", + "react-refractor": "^2.1.7" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "react": "^18", + "react-dom": "^18", + "react-is": "^18", + "styled-components": "^5.2 || ^6" + } + }, + "node_modules/@sanity/studio-secrets/node_modules/framer-motion": { + "version": "10.18.0", + "resolved": "https://registry.npmjs.org/framer-motion/-/framer-motion-10.18.0.tgz", + "integrity": "sha512-oGlDh1Q1XqYPksuTD/usb0I70hq95OUzmL9+6Zd+Hs4XV0oaISBa/UUMSjYiq6m8EUF32132mOJ8xVZS+I0S6w==", + "license": "MIT", + "dependencies": { + "tslib": "^2.4.0" + }, + "optionalDependencies": { + "@emotion/is-prop-valid": "^0.8.2" + }, + "peerDependencies": { + "react": "^18.0.0", + "react-dom": "^18.0.0" + }, + "peerDependenciesMeta": { + "react": { + "optional": true + }, + "react-dom": { + "optional": true + } + } + }, "node_modules/@sanity/telemetry": { "version": "0.7.7", "resolved": "https://registry.npmjs.org/@sanity/telemetry/-/telemetry-0.7.7.tgz", @@ -12841,6 +12938,124 @@ "react": "^18" } }, + "node_modules/sanity-plugin-cloudinary": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/sanity-plugin-cloudinary/-/sanity-plugin-cloudinary-1.1.3.tgz", + "integrity": "sha512-eaeTnIzumE34iI1iqPDxX/LWzlIAsEYB0khyGKzRFQfJ2qvET0L69T0UrEHo1LSDm3qLoa10Mm6xHI+sf6gRZw==", + "license": "MIT", + "dependencies": { + "@sanity/icons": "^2.0.0", + "@sanity/incompatible-plugin": "^1.0.4", + "@sanity/studio-secrets": "^2.0.1", + "@sanity/ui": "^1.0.0", + "nanoid": "^4.0.0" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "react": "^18", + "react-dom": "^18", + "sanity": "^3", + "styled-components": "^5.0 || ^6.0" + } + }, + "node_modules/sanity-plugin-cloudinary/node_modules/@floating-ui/react-dom": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@floating-ui/react-dom/-/react-dom-2.0.0.tgz", + "integrity": "sha512-Ke0oU3SeuABC2C4OFu2mSAwHIP5WUiV98O9YWoHV4Q5aT6E9k06DV0Khi5uYspR8xmmBk08t8ZDcz3TR3ARkEg==", + "license": "MIT", + "dependencies": { + "@floating-ui/dom": "^1.2.7" + }, + "peerDependencies": { + "react": ">=16.8.0", + "react-dom": ">=16.8.0" + } + }, + "node_modules/sanity-plugin-cloudinary/node_modules/@sanity/color": { + "version": "2.2.5", + "resolved": "https://registry.npmjs.org/@sanity/color/-/color-2.2.5.tgz", + "integrity": "sha512-tTi22KoKuER3sldXYl4c1Dq2zU7tMLDkljFiaUKVkBbu4PBvRGCFw75kXZnD2b4Bsp6vin+7sI+AKdCKRhfRuw==", + "license": "MIT" + }, + "node_modules/sanity-plugin-cloudinary/node_modules/@sanity/icons": { + "version": "2.11.8", + "resolved": "https://registry.npmjs.org/@sanity/icons/-/icons-2.11.8.tgz", + "integrity": "sha512-C4ViXtk6eyiNTQ5OmxpfmcK6Jw+LLTi9zg9XBUD15DzC4xTHaGW9SVfUa43YtPGs3WC3M0t0K59r0GDjh52HIg==", + "license": "MIT", + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "react": "^18" + } + }, + "node_modules/sanity-plugin-cloudinary/node_modules/@sanity/ui": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/@sanity/ui/-/ui-1.9.3.tgz", + "integrity": "sha512-AdWEVFaK0Snk6xxP0lGPVP3QQYKwzkfGFpFZnL9d6UtWt8yeuS8BMLVAzmXzg14hrqH50ex9nvNl3eq6a0MWiw==", + "license": "MIT", + "dependencies": { + "@floating-ui/react-dom": "2.0.0", + "@sanity/color": "^2.2.5", + "@sanity/icons": "^2.4.1", + "csstype": "^3.1.2", + "framer-motion": "^10.16.2", + "react-refractor": "^2.1.7" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "react": "^18", + "react-dom": "^18", + "react-is": "^18", + "styled-components": "^5.2 || ^6" + } + }, + "node_modules/sanity-plugin-cloudinary/node_modules/framer-motion": { + "version": "10.18.0", + "resolved": "https://registry.npmjs.org/framer-motion/-/framer-motion-10.18.0.tgz", + "integrity": "sha512-oGlDh1Q1XqYPksuTD/usb0I70hq95OUzmL9+6Zd+Hs4XV0oaISBa/UUMSjYiq6m8EUF32132mOJ8xVZS+I0S6w==", + "license": "MIT", + "dependencies": { + "tslib": "^2.4.0" + }, + "optionalDependencies": { + "@emotion/is-prop-valid": "^0.8.2" + }, + "peerDependencies": { + "react": "^18.0.0", + "react-dom": "^18.0.0" + }, + "peerDependenciesMeta": { + "react": { + "optional": true + }, + "react-dom": { + "optional": true + } + } + }, + "node_modules/sanity-plugin-cloudinary/node_modules/nanoid": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-4.0.2.tgz", + "integrity": "sha512-7ZtY5KTCNheRGfEFxnedV5zFiORN1+Y1N6zvPTnHQd8ENUvfaDBeuJDZb2bN/oXwXxu3qkTXDzy57W5vAmDTBw==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.js" + }, + "engines": { + "node": "^14 || ^16 || >=18" + } + }, "node_modules/sanity/node_modules/@portabletext/editor": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@portabletext/editor/-/editor-1.1.1.tgz", diff --git a/package.json b/package.json index d025b8e..b1d9e61 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "rxjs": "7.8.1", "sanity": "3.58.0", "sanity-plugin-asset-source-unsplash": "3.0.1", + "sanity-plugin-cloudinary": "^1.1.3", "server-only": "0.0.1", "styled-components": "6.1.13" }, diff --git a/sanity.config.ts b/sanity.config.ts index a84e364..82cb82b 100644 --- a/sanity.config.ts +++ b/sanity.config.ts @@ -8,6 +8,8 @@ import { defineConfig } from 'sanity' import { presentationTool } from 'sanity/presentation' import { structureTool } from 'sanity/structure' import { unsplashImageAsset } from 'sanity-plugin-asset-source-unsplash' +import { cloudinaryAssetSourcePlugin } from 'sanity-plugin-cloudinary' +import { cloudinarySchemaPlugin } from 'sanity-plugin-cloudinary' import { apiVersion, dataset, projectId, studioUrl } from '@/sanity/lib/api' import * as resolve from '@/sanity/plugins/resolve' @@ -45,6 +47,8 @@ export default defineConfig({ ], }, plugins: [ + cloudinaryAssetSourcePlugin(), + cloudinarySchemaPlugin(), structureTool({ structure: pageStructure([home, settings]), }), @@ -64,4 +68,20 @@ export default defineConfig({ // https://www.sanity.io/docs/the-vision-plugin visionTool({ defaultApiVersion: apiVersion }), ], + form: { + image: { + assetSources: (previousAssetSources, context) => { + if (context.currentUser?.roles.includes('cloudinaryAccess')) { + // appends cloudinary as an asset source + return [...previousAssetSources, cloudinaryImageSource] + } + if (context.currentUser?.roles.includes('onlyCloudinaryAccess')) { + // only use clooudinary as an asset source + return [cloudinaryImageSource] + } + // dont add cloudnary as an asset sources + return previousAssetSources + }, + }, + }, }) diff --git a/sanity/schemas/documents/project.ts b/sanity/schemas/documents/project.ts index f72108a..cf74cca 100644 --- a/sanity/schemas/documents/project.ts +++ b/sanity/schemas/documents/project.ts @@ -26,6 +26,16 @@ export default defineType({ isUnique: (value, context) => context.defaultIsUnique(value, context), }, validation: (rule) => rule.required(), + }), + defineField({ + + type: "array", + name: "cloudinaryList", + description: "Select images to add to the gallery. (not mandetory)", + of: [{ type: "cloudinary.asset" }], + title: "Gallery", + + }), defineField({ name: 'overview',