sanity-io / sanity-plugin-asset-source-unsplash

Search photos on Unsplash and use them directly inside of your Sanity Studio.
MIT License
17 stars 5 forks source link

Manually configure asset sources not working #146

Open shabith opened 5 months ago

shabith commented 5 months ago

Describe the bug

I tried to disable the asset source for a specific schema following the Manually configure asset sources section in README but it is not working.

To Reproduce

Steps to reproduce the behavior:

  1. Create a schema with field type image called movie-image
  2. Try to remove unsplash as asset source for that schema adding following code to the config
import { unsplashImageAsset, unsplashAssetSource } from 'sanity-plugin-asset-source-unsplash'

export default defineConfig({
  // ...
  plugins: [unsplashImageAsset()],
  form: {
    image: {
      assetSources: (previousAssetSources, { schema }) => {
        if (schema.name === 'movie-image') {
          // remove unsplash from movie-image types
          return previousAssetSources.filter((assetSource) => assetSource !== unsplashAssetSource)
        }
        return previousAssetSources
      },
    },
  },
})

Expected behavior

movie-image shouldn't have unsplash as in source dropdown

Which versions of Sanity are you using?

@sanity/cli (global) 3.29.1 (latest: 3.44.0) @sanity/astro 3.0.0 (latest: 3.1.3) @sanity/code-input 4.1.4 (up to date) @sanity/vision 3.41.1 (latest: 3.44.0) sanity 3.41.1 (latest: 3.44.0)

What operating system are you using?

Which versions of Node.js / npm are you running?

10.5.0 v20.11.0

Additional context

When I console log schema.name it returns undefined