Skip to content

Commit

Permalink
feat: Add sanity-plugin-cloudinary to package.json and sanity.config.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
hasanshahriar32 committed Oct 11, 2024
1 parent 04e1ba6 commit f2ecfe3
Show file tree
Hide file tree
Showing 4 changed files with 246 additions and 0 deletions.
215 changes: 215 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
20 changes: 20 additions & 0 deletions sanity.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -45,6 +47,8 @@ export default defineConfig({
],
},
plugins: [
cloudinaryAssetSourcePlugin(),
cloudinarySchemaPlugin(),
structureTool({
structure: pageStructure([home, settings]),
}),
Expand All @@ -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
},
},
},
})
10 changes: 10 additions & 0 deletions sanity/schemas/documents/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit f2ecfe3

Please sign in to comment.