Unknown type: svgUploadPreview. Valid types are: page, goal, array...

4 replies
Last updated: Oct 19, 2020
Hi all!I’m trying to install an svg inline field on Sanity Studio with
sanity-plugin-inline-svg
(https://npm.io/package/sanity-plugin-inline-svg ) but I’m getting this error :
goal documentfields<unnamed_type_@_index_0> svgUploadPreview
ERROR
Unknown type: svgUploadPreview. Valid types are: page, goal, array, block, boolean, datetime, date, document, email, file, geopoint, image, number, object, reference, slug, string, telephone, text and url
I did implement it like this in
schemas/goal.js
:
import { GiArcheryTarget as icon } from 'react-icons/gi';
import svgUploadPreview from 'sanity-plugin-inline-svg';

export default {
  name: 'goal',
  title: 'Objectifs',
  type: 'document',
  icon,
  fields: [
    {
      name: 'svgUpload',
      title: 'Icône',
      type: 'svgUploadPreview',
    },
    {
      name: 'title',
      title: 'Titre',
      type: 'string',
    },
    {
      name: 'list',
      title: 'Liste de capacités',
      type: 'array',
      of: [{ type: 'string' }],
    },
  ],
};
My
schemas/schema.js
file is like this :
import createSchema from 'part:@sanity/base/schema-creator';
import schemaTypes from 'all:part:@sanity/base/schema-type';

import page from './page';
import goal from './goal';

export default createSchema({
  name: 'default',
  types: schemaTypes.concat([page, goal]),
});
Before that, I did a

sanity install sanity-plugin-inline-svg
in my sanity folder and restart it after that.

I don’t understant what I did wrong. Thanks for any help on this
🙂
Oct 19, 2020, 1:47 PM
According to the README, you must import into your schema.js file:
import svgUploadPreview from 'sanity-plugin-inline-svg';
Oct 19, 2020, 1:52 PM
(and I believe it implicitly asks you to also make
svgUploadPreview
part of your schema types)
Oct 19, 2020, 1:55 PM
Ah ok ! thanks a lot Erlend ! it works !I did it like this in my
schema.js
file indeed :
import createSchema from 'part:@sanity/base/schema-creator';
import schemaTypes from 'all:part:@sanity/base/schema-type';
import svgUploadPreview from 'sanity-plugin-inline-svg';

import page from './page';
import goal from './goal';

export default createSchema({
  name: 'default',
  types: schemaTypes.concat([page, goal, svgUploadPreview]),
});
Oct 19, 2020, 1:58 PM
great 😄
Oct 19, 2020, 1:58 PM

Sanity.io – build remarkable experiences at scale

Sanity is a customizable solution that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.